次の方法で共有


operator!= (hash_map)

[!メモ]

この 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 型のオブジェクト。

戻り値

hash_mapsがではないtrue ; hash_mapsが等しい場合 false

解説

hash_mapのオブジェクトの比較は、要素のペアに比較に基づいています。2個のhash_mapsは、要素の数が同じで、対応する要素の値が同じ同じです。それ以外の場合は等しくありません。

Visual C++ .NET 2003では、<hash_map><hash_set> ヘッダー ファイルのメンバーはstdの名前空間に存在しなくなりましたが、ではなくstdextの名前空間に型。詳細については、「The stdext Namespace」を参照してください。

使用例

// 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

参照

関連項目

標準テンプレート ライブラリ