备注
此 API 已过时。替代为 unordered_map 类。
测试,如果运算符左侧的 hash_map 对象与右侧的 hash_map 对象不等于。
bool operator!=(
const hash_map <Key, Type, Traits, Allocator>& _Left,
const hash_map <Key, Type, Traits, Allocator>& _Right
);
参数
_Left
hash_map 类型的对象。_Right
hash_map 类型的对象。
返回值
true,如果 hash_maps 不相等;false,如果 hash_maps 相等。
备注
在 hash_map 对象之间的比较基于元素的一种比较成对。 两 hash_maps 相等,如果变量具有相同数量的元素,它们各自的元素具有相同的值。 否则为不相等。
在Visual C++ .NET 2003中,成员<hash_map> 和 <hash_set> 头文件不再在std命名空间,而是已经进入了stdext命名空间。 有关更多信息,请参见 stdext 命名空间。
示例
// hash_map_op_ne.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_map <int, int> hm1, hm2, hm3;
int i;
typedef pair <int, int> Int_Pair;
for ( i = 0 ; i < 3 ; i++ )
{
hm1.insert ( Int_Pair ( i, i ) );
hm2.insert ( Int_Pair ( i, i * i ) );
hm3.insert ( Int_Pair ( i, i ) );
}
if ( hm1 != hm2 )
cout << "The hash_maps hm1 and hm2 are not equal." << endl;
else
cout << "The hash_maps hm1 and hm2 are equal." << endl;
if ( hm1 != hm3 )
cout << "The hash_maps hm1 and hm3 are not equal." << endl;
else
cout << "The hash_maps hm1 and hm3 are equal." << endl;
}
要求
标头: <hash_map>
**命名空间:**stdext