function template
<unordered_map>

std::operators (unordered_multimap)

相等 (1)
template <class Key, class T, class Hash, class Pred, class Alloc>  bool operator== ( const unordered_multimap<Key,T,Hash,Pred,Alloc>& lhs,                    const unordered_multimap<Key,T,Hash,Pred,Alloc>& rhs );
不等 (2)
template <class Key, class T, class Hash, class Pred, class Alloc>  bool operator!= ( const unordered_multimap<Key,T,Hash,Pred,Alloc>& lhs,                    const unordered_multimap<Key,T,Hash,Pred,Alloc>& rhs );
Relational operators for unordered_multimap
These overloaded global operator functions perform the appropriate equality or inequality comparison operation between the unordered_multimap containers lhs and rhs.

相等比較的過程如下(如果在過程中找到確定的答案,則停止):

引數

lhs, rhs
unordered_multimap containers (to the left- and right-hand side of the operator, respectively), having both the same template parameters (, T, Hash, PredAlloc).

返回值

true如果條件成立,則為 true,並且false否則為 false。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// unordered_multimap comparisons
#include <iostream>
#include <string>
#include <unordered_map>

typedef std::unordered_multimap<std::string,int> stringmap;

int main ()
{
  stringmap a = { {"AAPL",100}, {"MSFT",200}, {"GOOG",50}, {"GOOG",20} };
  stringmap b = { {"GOOG",20}, {"MSFT",200}, {"AAPL",100}, {"GOOG",50} };
  stringmap c = { {"GOOG",70}, {"MSFT",200}, {"AAPL",100} };

  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 number of equivalent groups, where each is up to quadratic in number of elements (general case), but commonly linear if the relative order of elements between the equivalent groups is the same (such as when a container is a copy of another).
Worst case: quadratic in size.

迭代器有效性

沒有變化。

另見