rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

rw_hashmultimap< K, V, Hash, EQ, A > Class Template Reference
[STL Extension-based Collections]

Maintains a collection of mappings between two types K and V, implemented as a hash table of std::pair<K,V> instances where multiple occurrences of the same A instance are allowed. More...

#include <rw/stdex/hashmmap.h>

List of all members.

Public Types

typedef std::pair< const K, V > value_type
typedef K key_type
typedef impl_type::size_type size_type
typedef impl_type::difference_type difference_type
typedef impl_type::reference reference
typedef impl_type::const_reference const_reference
typedef impl_type::Iterator iterator
typedef impl_type::ConstIterator const_iterator
typedef Hash key_hash_type
typedef EQ key_equal_type

Public Member Functions

 rw_hashmultimap (size_type sz=1024, const Hash &h=Hash(), const EQ &eq=EQ())
 rw_hashmultimap (const rw_hashmultimap< K, V, Hash, EQ, A > &mmap)
 rw_hashmultimap (rw_hashmultimap< K, V, Hash, EQ, A > &&mmap)
 rw_hashmultimap (const value_type *first, const value_type *bound, size_type sz=1024, const Hash &h=Hash(), const EQ &eq=EQ())
 rw_hashmultimap (const_iterator first, const_iterator bound, size_type sz=1024, const Hash &h=Hash(), const EQ &eq=EQ())
 ~rw_hashmultimap ()
rw_hashmultimap< K, V, Hash,
EQ, A > & 
operator= (const rw_hashmultimap< K, V, Hash, EQ, A > &rhs)
rw_hashmultimap< K, V, Hash,
EQ, A > & 
operator= (rw_hashmultimap< K, V, Hash, EQ, A > &&rhs)
bool operator== (const rw_hashmultimap< K, V, Hash, EQ, A > &rhs) const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
bool empty () const
size_type size () const
size_type count (const key_type &key) const
const_iterator find (const key_type &key) const
iterator find (const key_type &key)
iterator lower_bound (const key_type &key)
const_iterator lower_bound (const key_type &key) const
iterator upper_bound (const key_type &key)
const_iterator upper_bound (const key_type &key) const
std::pair< iterator, iteratorequal_range (const key_type &key)
std::pair< const_iterator,
const_iterator
equal_range (const key_type &key) const
size_type capacity () const
bool equal_by_keys (const rw_hashmultimap< K, V, Hash, EQ, A > &rhs) const
float fill_ratio () const
void resize (size_t sz)
void swap (rw_hashmultimap< K, V, Hash, EQ, A > &other)
std::pair< iterator, bool > insert (const value_type &val)
iterator insert (iterator location_hint, const value_type &val)
std::pair< iterator, bool > insert (value_type &&val)
iterator insert (iterator location_hint, value_type &&val)
size_type insert (const value_type *first, const value_type *bound)
size_type insert (const_iterator first, const_iterator bound)
size_type erase (const key_type &key)
iterator erase (iterator iter)
iterator erase (iterator first, iterator bound)
void clear ()

Detailed Description

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
class rw_hashmultimap< K, V, Hash, EQ, A >

Class rw_hashmultimap<K,V,H,EQ,A> maintains a collection of mappings between K and V, implemented as a hash table of std::pair<const K,V> in which there may be many pairs with the same K instance. Since this is a value-based collection, objects are copied into and out of the collection. As with all classes that meet the ANSI associative container specification, rw_hashmap<K,V,H,EQ,A> provides for iterators that reference its elements. Operations that alter the contents of rw_hashmap<K,V,H,EQ,A> may invalidate other iterators that reference the container. Since the contents of rw_hashmap<K,V,H,EQ,A> are in pseudo-random order, the only iterator ranges that will usually make sense are the results of calling equal_range(), and the entire range from begin() to end().

Synopsis

 #include <rw/stdex/hashmmap.h>
 rw_hashmultimap<K,V,H,EQ,A=std::allocator<std::pair<const K,V> > >

Persistence

None


Member Typedef Documentation

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::ConstIterator rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator

The typedef for the const iterator.

Note:
Iterators over rw_hashmultimap<K,V,H,EQ,A> are forward iterators.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::const_reference rw_hashmultimap< K, V, Hash, EQ, A >::const_reference

Typedef for a const reference to a value in this container.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::difference_type rw_hashmultimap< K, V, Hash, EQ, A >::difference_type

Typedef for the type of difference between iterators.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::Iterator rw_hashmultimap< K, V, Hash, EQ, A >::iterator

The typedef for the non-const iterator.

Note:
Iterators over rw_hashmultimap<K,V,H,EQ,A> are forward iterators.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef EQ rw_hashmultimap< K, V, Hash, EQ, A >::key_equal_type

A typedef for the equality object.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef Hash rw_hashmultimap< K, V, Hash, EQ, A >::key_hash_type

A typedef for the hash object.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef K rw_hashmultimap< K, V, Hash, EQ, A >::key_type

Typedef for the type of key.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::reference rw_hashmultimap< K, V, Hash, EQ, A >::reference

Typedef for a non-const reference to a value in this container.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef impl_type::size_type rw_hashmultimap< K, V, Hash, EQ, A >::size_type

Typedef for the type used to index into this container.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
typedef std::pair<const K,V> rw_hashmultimap< K, V, Hash, EQ, A >::value_type

Typedef for the type of elements in this container.


Constructor & Destructor Documentation

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( size_type  sz = 1024,
const Hash &  h = Hash(),
const EQ &  eq = EQ() 
) [inline]

Constructs an empty rw_hashmultimap<K,V,H,EQ,A> with sz slots, using h as the hash object, and eq as the equality comparator.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( const rw_hashmultimap< K, V, Hash, EQ, A > &  mmap  )  [inline]

Constructs an rw_hashmultimap<K,V,H,EQ,A> which is a copy of mmap. Each element from mmap is copied into self.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( rw_hashmultimap< K, V, Hash, EQ, A > &&  mmap  )  [inline]

Move constructor. The constructed list takes ownership of the data owned by mmap.

Condition:
This method is only available on platforms with rvalue reference support.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( const value_type first,
const value_type bound,
size_type  sz = 1024,
const Hash &  h = Hash(),
const EQ &  eq = EQ() 
)

Constructs an rw_hashmultimap<K,V,H,EQ,A> with sz slots, using h as the hash object, and eq as the equality comparator, containing a copy of each pair referenced by the range starting with first and bounded by bound.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( const_iterator  first,
const_iterator  bound,
size_type  sz = 1024,
const Hash &  h = Hash(),
const EQ &  eq = EQ() 
)

Constructs an rw_hashmultimap<K,V,H,EQ,A> with sz slots, using h as the hash object, and eq as the equality comparator, containing a copy of each pair referenced by the range starting with first and bounded by bound.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap< K, V, Hash, EQ, A >::~rw_hashmultimap (  )  [inline]

Releases the memory used by the container's implementation.


Member Function Documentation

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::begin (  )  const [inline]

The iterator returned references the first item in self. If self is empty, the iterator is equal to end(). Note that because items are stored in pseudo-random order, this iterator might reference any item that has been stored in self.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::begin (  )  [inline]

The iterator returned references the first item in self. If self is empty, the iterator is equal to end(). Note that because items are stored in pseudo-random order, this iterator might reference any item that has been stored in self.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::capacity (  )  const [inline]

Returns the number of slots in the hash table that self uses.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
void rw_hashmultimap< K, V, Hash, EQ, A >::clear (  )  [inline]

A synonym for erase(begin(),end()) .

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::count ( const key_type key  )  const [inline]

Returns the number of pairs in self which have key EQ to their first element.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
bool rw_hashmultimap< K, V, Hash, EQ, A >::empty (  )  const [inline]

Returns true if self is empty.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::end (  )  const [inline]

The iterator returned marks the location "off the end" of self. It cannot be dereferenced.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::end (  )  [inline]

The iterator returned marks the location "off the end" of self. It cannot be dereferenced.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
bool rw_hashmultimap< K, V, Hash, EQ, A >::equal_by_keys ( const rw_hashmultimap< K, V, Hash, EQ, A > &  rhs  )  const [inline]

Returns true if self and rhs have the same size, and if for each distinct key_type in self, self and rhs have the same number of pairs with first parts that tests EQ to that instance. Note that this method does not compare the V (second) part of the pair of the items, so it will run slightly faster than operator==().

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
std::pair<const_iterator,const_iterator> rw_hashmultimap< K, V, Hash, EQ, A >::equal_range ( const key_type key  )  const [inline]

Returns std::pair<const_iterator,const_iterator>(lower_bound(), upper_bound()). The methods, upper_bound() and lower_bound(), have special meaning for hash-based collections.

Note:
All items which are EQ to each other are in consecutive iterator locations. Thus, while equal_range() is useful, no other range (except the entire range of the hash table) is likely to be meaningful.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
std::pair<iterator,iterator> rw_hashmultimap< K, V, Hash, EQ, A >::equal_range ( const key_type key  )  [inline]

Returns std::pair<iterator,iterator>(lower_bound(), upper_bound()). The methods, upper_bound() and lower_bound(), have special meaning for hash-based collections.

Note:
All items which are EQ to each other are in consecutive iterator locations. Thus, while equal_range() is useful, no other range (except the entire range of the hash table) is likely to be meaningful.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::erase ( iterator  first,
iterator  bound 
) [inline]

Removes each element in the range which begins with first and is bounded by bound. Returns an iterator referencing bound. If first does not reference an item in self (and if first and bound are not equal), the effect is undefined.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::erase ( iterator  iter  )  [inline]

Removes the element referenced by iter and returns an iterator referencing the next element. If iter does not reference an item in self, the result is undefined.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::erase ( const key_type key  )  [inline]

Removes all pairs in self for which the first part is EQ to key, and returns the number of removed elements.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
float rw_hashmultimap< K, V, Hash, EQ, A >::fill_ratio (  )  const [inline]

Returns the result of calculating size() / capacity().

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::find ( const key_type key  )  [inline]

Returns an iterator referencing some pair with key as its first element, if such a pair is contained in self, else returns end().

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::find ( const key_type key  )  const [inline]

Returns a const_iterator referencing some pair with key as its first element, if such a pair is contained in self, else returns end().

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::insert ( const_iterator  first,
const_iterator  bound 
) [inline]

For each element in the range beginning with first and bounded by bound, the element is copied into self. Returns the number of elements inserted.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::insert ( const value_type first,
const value_type bound 
) [inline]

For each element in the range beginning with first and bounded by bound, the element is copied into self. Returns the number of elements inserted.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::insert ( iterator  location_hint,
value_type &&  val 
) [inline]

Inserts the pair val, returning 1. Note that the first argument is provided only for conformance with the ANSI associative container specification, and is ignored by the method since hash table look up can be done in constant time.

Condition:
This method is only available on platforms with rvalue reference support.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
std::pair<iterator,bool> rw_hashmultimap< K, V, Hash, EQ, A >::insert ( value_type &&  val  )  [inline]

Inserts the pair val, and returns a pair with an iterator referencing the new element and true.

Condition:
This method is only available on platforms with rvalue reference support.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::insert ( iterator  location_hint,
const value_type val 
) [inline]

Inserts the pair val, returning 1. Note that the first argument is provided only for conformance with the ANSI associative container specification, and is ignored by the method since hash table look up can be done in constant time.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
std::pair<iterator,bool> rw_hashmultimap< K, V, Hash, EQ, A >::insert ( const value_type val  )  [inline]

Inserts the pair val, and returns a pair with an iterator referencing the new element and true.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::lower_bound ( const key_type key  )  const [inline]

Returns the lower bound of key in self. This has a special meaning for hash-based collections.

Since hash tables are intrinsically unordered, we have relaxed the meaning very slightly so that lower_bound() returns an iterator which points to one of the following:

  • "just past" the hash table slot where key would have been but was not.
  • the "first" iterator which references something EQ to key.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::lower_bound ( const key_type key  )  [inline]

Returns the lower bound of key in self. This has a special meaning for hash-based collections.

Since hash tables are intrinsically unordered, we have relaxed the meaning very slightly so that lower_bound() returns an iterator which points to one of the following:

  • "just past" the hash table slot where key would have been but was not.
  • the "first" iterator which references something EQ to key.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap<K,V,Hash,EQ,A>& rw_hashmultimap< K, V, Hash, EQ, A >::operator= ( rw_hashmultimap< K, V, Hash, EQ, A > &&  rhs  )  [inline]

Move assignment. Self takes ownership of the data owned by rhs.

Condition:
This method is only available on platforms with rvalue reference support.
template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
rw_hashmultimap<K,V,Hash,EQ,A>& rw_hashmultimap< K, V, Hash, EQ, A >::operator= ( const rw_hashmultimap< K, V, Hash, EQ, A > &  rhs  )  [inline]

Sets self to have the same capacity, Hash and EQ as rhs, removes all self's current contents, and replaces them with copies of the elements in rhs.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
bool rw_hashmultimap< K, V, Hash, EQ, A >::operator== ( const rw_hashmultimap< K, V, Hash, EQ, A > &  rhs  )  const

Returns true if self and rhs have the same number of elements, and for each value_type in self, there is exactly one corresponding value_type in rhs that has a first part for which the EQ object in self returns true, and a second part for which operator==() returns true. The need to test both parts, and ensure that the matches are one-to-one means that this operator may be significantly slower than the method equal_by_keys().

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
void rw_hashmultimap< K, V, Hash, EQ, A >::resize ( size_t  sz  )  [inline]

Resizes self's hash table to have sz slots; and re-hashes all self's elements into the new table. Can be very expensive if self holds many elements.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
size_type rw_hashmultimap< K, V, Hash, EQ, A >::size (  )  const [inline]

Returns the number of items currently held in self.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
void rw_hashmultimap< K, V, Hash, EQ, A >::swap ( rw_hashmultimap< K, V, Hash, EQ, A > &  other  )  [inline]

Exchanges the contents of self with other, including the Hash and EQ objects. This method does not copy or destroy any of the items exchanged but exchanges the underlying hash tables.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::upper_bound ( const key_type key  )  const [inline]

Returns the upper bound of key in self. This has a special meaning for hash-based collections.

Since hash tables are intrinsically unordered, we have relaxed the meaning very slightly so that upper_bound() returns an iterator which points to one of the following:

  • "just past" the hash table slot where key would have been but was not.
  • "just past" the "last" iterator which references something EQ to key.

template<class K, class V, class Hash, class EQ, class A = std:: allocator < std::pair<const K,V> >>
iterator rw_hashmultimap< K, V, Hash, EQ, A >::upper_bound ( const key_type key  )  [inline]

Returns the upper bound of key in self. This has a special meaning for hash-based collections.

Since hash tables are intrinsically unordered, we have relaxed the meaning very slightly so that upper_bound() returns an iterator which points to one of the following:

  • "just past" the hash table slot where key would have been but was not.
  • "just past" the "last" iterator which references something EQ to key.
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.