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");
}
None.
Member | Where defined | Description |
key_type | AssociativeContainer | The hash_multimap 's key type, Key . |
data_type | PairAssociativeContainer | The type of object associated with the keys. |
value_type | PairAssociativeContainer | The type of object, pair<const key_type, data_type> , stored in the hash_multimap. |
hasher | HashedAssociativeContainer | The hash_multimap 's HashFunction. |
key_equal | HashedAssociativeContainer | functors that compares keys for equality. |
pointer | Container | Pointer to T . |
reference | Container | Reference to T |
const_reference | Container | Const reference to T |
size_type | Container | An unsigned integral type. |
difference_type | Container | A signed integral type. |
iterator | Container | Iterator used to iterate through a hash_multimap . [1] |
const_iterator | Container | Const iterator used to iterate through a hash_multimap . |
iterator begin() | Container | Returns an iterator pointing to the beginning of the hash_multimap . |
iterator end() | Container | Returns an iterator pointing to the end of the hash_multimap . |
const_iterator begin() const | Container | Returns an const_iterator pointing to the beginning of the hash_multimap . |
const_iterator end() const | Container | Returns an const_iterator pointing to the end of the hash_multimap . |
size_type size() const | Container | Returns the size of the hash_multimap . |
size_type max_size() const | Container | Returns the largest possible size of the hash_multimap . |
bool empty() const | Container | true if the hash_multimap 's size is 0 . |
size_type bucket_count() const | HashedAssociativeContainer | Returns the number of buckets used by the hash_multimap . |
void resize(size_type n) | HashedAssociativeContainer | Increases the bucket count to at least n . |
hasher hash_funct() const | HashedAssociativeContainer | Returns the hasher object used by the hash_multimap . |
key_equal key_eq() const | HashedAssociativeContainer | Returns the key_equal object used by the hash_multimap . |
hash_multimap() | Container | Creates an empty hash_multimap . |
hash_multimap(size_type n) | HashedAssociativeContainer | Creates an empty hash_multimap with at least n buckets. |
hash_multimap(size_type n,
const hasher& h)
| HashedAssociativeContainer | Creates an empty hash_multimap with at least n buckets, using h as the hash function. |
hash_multimap(size_type n,
const hasher& h,
const key_equal& k)
| HashedAssociativeContainer | Creates an empty hash_multimap with at least n buckets, using h as the hash function and k as the key equal function. |
template <class InputIterator>
hash_multimap(InputIterator, InputIterator)
[2] | MultipleHashedAssociativeContainer | Creates a hash_multimap with a copy of a range. |
template <class InputIterator>
hash_multimap(InputIterator, InputIterator,
size_type n)
[2] | MultipleHashedAssociativeContainer | Creates a hash_multimap with a copy of a range and a bucket count of at least n . |
template <class InputIterator>
hash_multimap(InputIterator, InputIterator,
size_type n, const hasher& h)
[2] | MultipleHashedAssociativeContainer | Creates a hash_multimap with a copy of a range and a bucket count of at least n , using h as the hash function. |
template <class InputIterator>
hash_multimap(InputIterator, InputIterator,
size_type n, const hasher& h,
const key_equal& k)
[2] | MultipleHashedAssociativeContainer | Creates a hash_multimap with a copy of a range and a bucket count of at least n , using h as the hash function and k as the key equal function. |
hash_multimap(const hash_multimap&) | Container | The copy constructor. |
hash_multimap& operator=(const hash_multimap&) | Container | The assignment operator |
void swap(hash_multimap&) | Container | Swaps the contents of two hash_multimaps. |
iterator insert(const value_type& x) | MultipleAssociativeContainer | Inserts x into the hash_multimap . |
template <class InputIterator>
void insert(InputIterator, InputIterator)
[2] | MultipleAssociativeContainer | Inserts a range into the hash_multimap . |
void erase(iterator pos) | AssociativeContainer | Erases the element pointed to by pos . |
size_type erase(const key_type& k) | AssociativeContainer | Erases the element whose key is k . |
void erase(iterator first, iterator last) | AssociativeContainer | Erases all elements in a range. |
void clear() | AssociativeContainer | Erases all of the elements. |
const_iterator find(const key_type& k) const | AssociativeContainer | Finds an element whose key is k . |
iterator find(const key_type& k) | AssociativeContainer | Finds an element whose key is k . |
size_type count(const key_type& k) const | AssociativeContainer | Counts the number of elements whose key is k . |
| AssociativeContainer | Finds a range containing all elements whose key is k . |
| AssociativeContainer | Finds a range containing all elements whose key is k . |
bool operator==(const hash_multimap&,
const hash_multimap&)
| HashedAssociativeContainer | Tests two hash_multimaps for equality. This is a global function, not a member function. |