function template
<unordered_map>
std::operators (unordered_multimap)
| equality (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 ); |
|---|---|
| inequality (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
The procedure for the equality comparison is as follows (stopping at any point if the procedure finds a conclusive answer):
- First, the sizes are compared (size).
- For every group with equivalent keys (such as those returned by equal_range):
- sizes are compared (count).
- all possible permutations of each group are compared (permutation).
Note that the unordered_multimap::hash_function and unordered_multimap::key_eq objects are expected to have the same behavior in both lhs and rhs.
Parameters
- lhs, rhs
- unordered_multimap containers (to the left- and right-hand side of the operator, respectively), having both the same template parameters (Key, T, Hash, Pred and Alloc).
Return Value
true if the condition holds, and false otherwise.Example
|
|
Output:
a and b are equal b and c are not equal
Complexity
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.
Iterator validity
No changes.See also
- unordered_multimap::equal_range
- Get range of elements with specific key (public member function)
- unordered_multimap::operator=
- Assign content (public member function)