標頭 <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
如果 s 不相等,則為 ;false
如果 相等則為 。
備註
對象之間的 unordered_set
比較不會受到物件儲存其元素的任意順序所影響。 如果元素數目相同,且一個容器中的元素是另一個容器中元素的排列,則兩 unordered_set
者相等。 反之則為不相等。
範例
// 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
如果 s 相等,則為 ;false
如果 它們不相等則為 。
備註
對象之間的 unordered_set
比較不會受到物件儲存其元素的任意順序所影響。 如果元素數目相同,且一個容器中的元素是另一個容器中元素的排列,則兩 unordered_set
者相等。 反之則為不相等。
範例
// 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
如果 s 不相等,則為 ;false
如果 相等則為 。
備註
對象之間的 unordered_multiset
比較不會受到物件儲存其元素的任意順序所影響。 如果元素數目相同,且一個容器中的元素是另一個容器中元素的排列,則兩 unordered_multiset
者相等。 反之則為不相等。
範例
// 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
如果 s 相等,則為 ;false
如果 它們不相等則為 。
備註
對象之間的 unordered_multiset
比較不會受到物件儲存其元素的任意順序所影響。 如果元素數目相同,且一個容器中的元素是另一個容器中元素的排列,則兩 unordered_multiset
者相等。 反之則為不相等。
範例
// 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