function template
<unordered_set>
std::operators (unordered_multiset)
相等 (1) | template <class Key, class Hash, class Pred, class Alloc> bool operator== ( const unordered_multiset<Key,Hash,Pred,Alloc>& lhs, const unordered_multiset<Key,Hash,Pred,Alloc>& rhs ); |
---|
不等 (2) | template <class Key, class Hash, class Pred, class Alloc> bool operator!= ( const unordered_multiset<Key,Hash,Pred,Alloc>& lhs, const unordered_multiset<Key,Hash,Pred,Alloc>& rhs ); |
---|
Relational operators for unordered_multiset
These overloaded global operator functions perform the appropriate equality or inequality comparison operation between the unordered_multiset containers lhs and rhs.
相等比较的过程如下(如果在过程中找到确定的答案,则停止):
参数
- lhs, rhs
- unordered_multiset containers (to the left- and right-hand side of the operator, respectively), having both the same template parameters (键, Hash, Pred和Alloc).
返回值
true如果条件成立,则为 true,并且false否则为 false。
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
// unordered_multiset comparisons
#include <iostream>
#include <string>
#include <unordered_set>
int main ()
{
std::unordered_multiset<std::string>
a = {"AAPL","MSFT","GOOG"},
b = {"MSFT","GOOG","AAPL"},
c = {"MSFT","GOOG","AAPL","AAPL"};
if (a==b) std::cout << "a and b are equal\n";
if (b!=c) std::cout << "b and c are not equal\n";
return 0;
}
|
输出
a and b are equal
b and c are not equal
|
复杂度
Average case: linear in size.
Worst case: quadratic in size.