Hashed Associative Container Tests two hash_multisets for equality. This is a global function, not a member function.
New members

All of hash_multiset's members are defined in the Multiple Hashed Associative Container and Simple Associative Container requirements. Hash_multiset does not introduce any new members.

Notes

[1] This member function relies on member template functions, which at present (early 1998) are not supported by all compilers. If your compiler supports member templates, you can call this function with any type of input iterator. If your compiler does not yet support member templates, though, then the arguments must either be of type const value_type* or of type hash_multiset::const_iterator.

See also

Associative Container, Hashed Associative Container, Simple Associative Container, Multiple Hashed Associative Container, set, map, multiset, multimap, hash_set, hash_map, hash_multimap

hash_multimap<Key, Data, HashFcn, EqualKey, Alloc>

Category: containers

Component type: type

Description

Hash_multimap is a Hashed Associative Container that associates objects of type Key with objects of type Data. Hash_multimap is a Pair Associative Container, meaning that its value type is pair<const Key, Data>. It is also a Multiple Associative Container, meaning that there is no limit on the number of elements whose keys may compare equal using EqualKey.

Looking up an element in a hash_multimap by its key is efficient, so hash_multimap is useful for 'dictionaries' where the order of elements is irrelevant. If it is important for the elements to be in a particular order, however, then multimap is more appropriate.

Example

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');

}

Definition

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.

Template parameters
Parameter Description Default
Key The hash_multimap's key type. This is also defined as hash_multimap::key_type.
Data The hash_multimap's data type. This is also defined as hash_multimap::data_type.
HashFcn The hash function used by the hash_multimap. This is also defined as hash_multimap::hasher. hash<Key>
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату