equality (1) |
template <class Key, class T, class Hash, class Pred, class Alloc> bool operator== ( const unordered_map<Key,T,Hash,Pred,Alloc>& lhs, const unordered_map<Key,T,Hash,Pred,Alloc>& rhs ); |
inequality (2) |
template <class Key, class T, class Hash, class Pred, class Alloc> bool operator!= ( const unordered_map<Key,T,Hash,Pred,Alloc>& lhs, const unordered_map<Key,T,Hash,Pred,Alloc>& rhs ); |
// unordered_map comparisons #include <iostream> #include <string> #include <unordered_map> typedef std::unordered_map<std::string,std::string> stringmap; int main () { stringmap a = { {"AAPL","Apple"}, {"MSFT","Microsoft"}, {"GOOG","Google"} }; stringmap b = { {"MSFT","Microsoft"}, {"GOOG","Google"}, {"AAPL","Apple"} }; stringmap c = { {"MSFT","Microsoft Corp."}, {"GOOG","Google Inc."}, {"AAPL","Apple Inc."} }; 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; } |
unordered_map::equal_range | 获取具有特定键的元素范围(公众成员函数) |
unordered_map::operator= | 复制容器内容(公众成员函数) |