次の方法で共有


operator!= (unordered_set)

演算子の左側のオブジェクトが右側の unordered_set unordered_setのオブジェクトと等しくないかどうかをテストします。

bool operator!=(
   const unordered_set <Key, Hash, Pred, Allocator>& _Left,
   const unordered_set <Key, Hash, Pred, Allocator>& _Right
);

パラメーター

  • _Left
    unordered_set 型のオブジェクト。

  • _Right
    unordered_set 型のオブジェクト。

戻り値

unordered_setsがではないtrue ; それらが等しい場合 false。

解説

unordered_setのオブジェクトの比較は、要素を格納する任意の順序に影響されません。2個のunordered_setsの要素の数が同じで、1種類のコンテナー要素が他のコンテナー要素の順列場合は等しくなります。それ以外の場合は等しくありません。

使用例

// unordered_set_ne.cpp 
// compile by using: cl.exe /EHsc /nologo /W4 /MTd 
#include <unordered_set> 
#include <iostream> 
#include <ios>

int main() 
{ 
    using namespace std;

    unordered_set<char> c1, c2, c3;

    c1.insert('a'); 
    c1.insert('b'); 
    c1.insert('c'); 

    c2.insert('c'); 
    c2.insert('a'); 
    c2.insert('d'); 

    c3.insert('c'); 
    c3.insert('a'); 
    c3.insert('b'); 

   cout << boolalpha;
   cout << "c1 != c2: " << (c1 != c2) << endl; 
   cout << "c1 != c3: " << (c1 != c3) << endl; 
   cout << "c2 != c3: " << (c2 != c3) << endl; 

    return (0); 
} 

出力

c1 != c2: true

c1 != c3: false

c2 != c3: true

必要条件

ヘッダー : <unordered_set>

名前空間: std

参照

関連項目

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