测试运算符左侧的 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_sets 不相等;false,如果它们相等。
备注
在 unordered_set 对象之间的比较不会使其受到影响。它们存储元素的任意顺序的。 两 unordered_sets 相等,如果变量具有相同数量的元素,在容器的元素是元素的排列在其他容器中。 否则为不相等。
示例
// 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