| Hashed Associative Container | Tests two hash_multisets for equality. This is a global function, not a member function. |
All of
[1] This member function relies on
Associative Container, Hashed Associative Container, Simple Associative Container, Multiple Hashed Associative Container,
hash_multimap<Key, Data, HashFcn, EqualKey, Alloc>
Category: containers
Component type: type
Looking up an element in a
struct eqstr {
bool operator()(const char* s1, const char* s2) const {
return strcmp(s1, s2) == 0;
}
};
typedef hash_multimap<const char*, int, hash<const char*>, eqstr> map_type;
void lookup(const map_type& Map, const char* str) {
cout << str << ': ';
pair<map_type::const_iterator, map_type::const_iterator> p = Map.equal_range (str);
for (map_type::const_iterator i = p.first; i != p.second; ++i) cout << (*i).second << ' ';
cout << endl;
}
int main() {
map_type M;
M.insert(map_type::value_type('H', 1));
M.insert(map_type::value_type('H', 2));
M.insert(map_type::value_type('C', 12));
M.insert(map_type::value_type('C', 13));
M.insert(map_type::value_type('O', 16));
M.insert(map_type::value_type('O', 17));
M.insert(map_type::value_type('O', 18));
M.insert(map_type::value_type('I', 127));
lookup(M, 'I');
lookup(M, 'O');
lookup(M, 'Rn');
}
Defined in the header hash_map, and in the backward-compatibility header hash_map.h. This class is an SGI extension; it is not part of the C++ standard.
| Parameter | Description | Default |
|---|---|---|
Key | The hash_multimap's key type. This is also defined as | |
Data | The hash_multimap's data type. This is also defined as | |
HashFcn | The hash function used by the hash_multimap. This is also defined as | hash<Key> |
