<unordered_set>
ヘッダーには、次の演算子が用意されています。
operator!=
演算子の左側の 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
型オブジェクト。
戻り値
true
unordered_set
が等しくない場合はfalse
。等しい場合は。
解説
unordered_set
オブジェクト間の比較は、要素を格納する任意の順序の影響を受けません。 2 つの unordered_set
が同じ数の要素を持ち、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
operator==
演算子の左側の 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
型オブジェクト。
戻り値
true
unordered_set
が等しい場合はfalse
。等しくない場合は。
解説
unordered_set
オブジェクト間の比較は、要素を格納する任意の順序の影響を受けません。 2 つの unordered_set
が同じ数の要素を持ち、1 つのコンテナー内の要素がもう一方のコンテナー内の要素の順列である場合、同じです。 それ以外の場合は等しくありません。
例
// unordered_set_eq.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: false
c1 == c3: true
c2 == c3: false
operator!=
(multiset)
演算子の左側の unordered_multiset
オブジェクトが右側の unordered_multiset
オブジェクトと等しくないかどうかをテストします。
bool operator!=(const unordered_multiset <Key, Hash, Pred, Allocator>& left, const unordered_multiset <Key, Hash, Pred, Allocator>& right);
パラメーター
left
unordered_multiset
型オブジェクト。
right
unordered_multiset
型オブジェクト。
戻り値
true
unordered_multiset
が等しくない場合はfalse
。等しい場合は。
解説
unordered_multiset
オブジェクト間の比較は、要素を格納する任意の順序の影響を受けません。 2 つの unordered_multiset
が同じ数の要素を持ち、1 つのコンテナー内の要素がもう一方のコンテナー内の要素の順列である場合、同じです。 それ以外の場合は等しくありません。
例
// unordered_multiset_ne.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>
int main()
{
using namespace std;
unordered_multiset<char> c1, c2, c3;
c1.insert('a');
c1.insert('b');
c1.insert('c');
c1.insert('c');
c2.insert('c');
c2.insert('c');
c2.insert('a');
c2.insert('d');
c3.insert('c');
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
operator==
(multiset)
演算子の左側の unordered_multiset
オブジェクトが右側の unordered_multiset
オブジェクトと等しいかどうかをテストします。
bool operator==(const unordered_multiset <Key, Hash, Pred, Allocator>& left, const unordered_multiset <Key, Hash, Pred, Allocator>& right);
パラメーター
left
unordered_multiset
型オブジェクト。
right
unordered_multiset
型オブジェクト。
戻り値
true
unordered_multiset
が等しい場合はfalse
。等しくない場合は。
解説
unordered_multiset
オブジェクト間の比較は、要素を格納する任意の順序の影響を受けません。 2 つの unordered_multiset
が同じ数の要素を持ち、1 つのコンテナー内の要素がもう一方のコンテナー内の要素の順列である場合、同じです。 それ以外の場合は等しくありません。
例
// unordered_multiset_eq.cpp
// compile by using: cl.exe /EHsc /nologo /W4 /MTd
#include <unordered_set>
#include <iostream>
#include <ios>
int main()
{
using namespace std;
unordered_multiset<char> c1, c2, c3;
c1.insert('a');
c1.insert('b');
c1.insert('c');
c1.insert('c');
c2.insert('c');
c2.insert('c');
c2.insert('a');
c2.insert('d');
c3.insert('c');
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: false
c1 == c3: true
c2 == c3: false