SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
rw_hashmultimap< K, V, Hash, EQ, A > Class Template Reference

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

#include <rw/stdex/hashmmap.h>

Public Types

typedef impl_type::allocator_type allocator_type
 
typedef impl_type::const_iterator const_iterator
 
typedef impl_type::const_pointer const_pointer
 
typedef impl_type::const_reference const_reference
 
typedef impl_type::difference_type difference_type
 
typedef impl_type::hasher hasher
 
typedef impl_type::iterator iterator
 
typedef impl_type::key_equal key_equal_type
 
typedef impl_type::hasher key_hash_type
 
typedef impl_type::key_type key_type
 
typedef impl_type::key_policy::mapped_type mapped_type
 
typedef impl_type::pointer pointer
 
typedef impl_type::reference reference
 
typedef impl_type::size_type size_type
 
typedef impl_type::value_type value_type
 

Public Member Functions

 rw_hashmultimap (const rw_hashmultimap &other)
 
template<typename InputIterator >
 rw_hashmultimap (InputIterator first, InputIterator last, size_type cap=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type())
 
 rw_hashmultimap (rw_hashmultimap &&other)
 
 rw_hashmultimap (size_type cap=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type())
 
 ~rw_hashmultimap (void)
 
iterator begin (void)
 
const_iterator begin (void) const
 
size_type capacity (void) const
 
const_iterator cbegin (void) const
 
const_iterator cend (void) const
 
void clear (void)
 
size_type count (const key_type &key) const
 
bool empty (void) const
 
iterator end (void)
 
const_iterator end (void) const
 
bool equal_by_keys (const rw_hashmultimap &rhs) const
 
std::pair< iterator, iteratorequal_range (const key_type &key)
 
std::pair< const_iterator, const_iteratorequal_range (const key_type &key) const
 
size_type erase (const key_type &key)
 
iterator erase (iterator iter)
 
iterator erase (iterator iter, iterator bound)
 
float fill_ratio (void) const
 
iterator find (const key_type &key)
 
const_iterator find (const key_type &key) const
 
std::pair< iterator, bool > insert (const value_type &val)
 
template<typename InputIterator >
size_type insert (InputIterator first, InputIterator last)
 
iterator insert (iterator hint, const value_type &val)
 
iterator insert (iterator, value_type &&val)
 
std::pair< iterator, bool > insert (value_type &&val)
 
iterator lower_bound (const key_type &key)
 
const_iterator lower_bound (const key_type &key) const
 
rw_hashmultimapoperator= (const rw_hashmultimap &rhs)
 
rw_hashmultimapoperator= (rw_hashmultimap &&rhs)
 
void resize (size_t cap)
 
size_type size (void) const
 
void swap (rw_hashmultimap &other)
 
iterator upper_bound (const key_type &key)
 
const_iterator upper_bound (const key_type &key) const
 

Related Symbols

(Note that these are not member symbols.)

template<class K , class V , class Hash , class EQ , class A >
bool operator!= (const rw_hashmultimap< K, V, Hash, EQ, A > &lhs, const rw_hashmultimap< K, V, Hash, EQ, A > &rhs)
 
template<class K , class V , class Hash , class EQ , class A >
bool operator== (const rw_hashmultimap< K, V, Hash, EQ, A > &lhs, const rw_hashmultimap< K, V, Hash, EQ, A > &rhs)
 

Detailed Description

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

Class rw_hashmultimap maintains a collection mapping between instances of K (the key) and V (the value), implemented as a hash table of std::pair<const K,V> in which there may be more than one instance of any given K. 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_hashmultimap provides for iterators that reference its elements. Since the contents of rw_hashset are in psuedo-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().

Hash must provide a const function that takes a single argument convertible to type K and returns a value of type size_t.

Note
Any two keys that are equivalent must hash to the same value.

Key equality is determined by an equality function of type EQ, which takes two arguments convertible to type K and returns a value of type bool.

Synopsis
#include <rw/stdex/hashmmap.h>
Maintains a collection of mappings between two types K and V, implemented as a hash table of std::pai...
Definition hashmmap.h:59
Persistence
None

Member Typedef Documentation

◆ allocator_type

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

A type representing the allocator type for the container.

◆ const_iterator

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

A type that provides a const forward iterator over the elements in the container.

◆ const_pointer

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

A type that provides a const pointer to an element in the container.

◆ const_reference

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

A type that provides a const reference to an element in the container.

◆ difference_type

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

A signed integral type used to indicate the distance between two valid iterators on the same container.

◆ hasher

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

A type representing the hash function.

◆ iterator

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

A type that provides a forward iterator over the elements in the container.

◆ key_equal_type

template<class K , class V , class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator<std::pair<const K, V> >>
typedef impl_type::key_equal rw_hashmultimap< K, V, Hash, EQ, A >::key_equal_type

A type representing the key equality function.

◆ key_hash_type

template<class K , class V , class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator<std::pair<const K, V> >>
typedef impl_type::hasher rw_hashmultimap< K, V, Hash, EQ, A >::key_hash_type
Deprecated
As of SourcePro 12.5, use hasher instead.

A type representing the hash function.

◆ key_type

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

A type representing the type of keys used in the container.

◆ mapped_type

template<class K , class V , class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator<std::pair<const K, V> >>
typedef impl_type::key_policy::mapped_type rw_hashmultimap< K, V, Hash, EQ, A >::mapped_type

A type representing the type of mapped values used in the container.

◆ pointer

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

A type that provides a pointer to an element in the container.

◆ reference

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

A type that provides a reference to an element in the container.

◆ size_type

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

An unsigned integral type used for counting the number of elements in the container.

◆ value_type

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

A type representing the value stored in the container.

Constructor & Destructor Documentation

◆ rw_hashmultimap() [1/4]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( size_type cap = 64,
const hasher & h = hasher(),
const key_equal_type & eq = key_equal_type() )
inline

Constructs an empty rw_hashmultimap with cap buckets, using h as the hash function object, and eq as the equality function object.

Note
If the value specified for cap is zero, the default number of buckets is used.

◆ rw_hashmultimap() [2/4]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( const rw_hashmultimap< K, V, Hash, EQ, A > & other)
inline

Constructs an rw_hashmultimap that is a copy of other. Each element from other is copied into self.

◆ rw_hashmultimap() [3/4]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( rw_hashmultimap< K, V, Hash, EQ, A > && other)
inline

Move constructor. The constructed rw_hashmultimap takes ownership of the data owned by other.

Condition:
This method is available only on platforms with rvalue reference support.

◆ rw_hashmultimap() [4/4]

template<class K , class V , class Hash , class EQ , class A >
template<typename InputIterator >
rw_hashmultimap< K, V, Hash, EQ, A >::rw_hashmultimap ( InputIterator first,
InputIterator last,
size_type cap = 64,
const hasher & h = hasher(),
const key_equal_type & eq = key_equal_type() )
inline

Constructs an rw_hashmultimap containing a copy of the pair elements in the range [first, last). The rw_hashmultimap instance has cap buckets, uses h as its hash function object, and eq as its equality function object.

InputIterator is an input iterator type that points to elements that are convertible to value_type objects.

Note
If the value specified for cap is zero, the default number of buckets is used.

◆ ~rw_hashmultimap()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::~rw_hashmultimap ( void )
inline

The destructor releases the memory used by the container's implementation.

Member Function Documentation

◆ begin() [1/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::begin ( void )
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

◆ begin() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::begin ( void ) const
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

◆ capacity()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::size_type rw_hashmultimap< K, V, Hash, EQ, A >::capacity ( void ) const
inline

Returns the number of buckets in the container.

◆ cbegin()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::cbegin ( void ) const
inline

Returns an iterator referring to the first element in the container.

If the container is empty, returns end().

◆ cend()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::cend ( void ) const
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

◆ clear()

template<class K , class V , class Hash , class EQ , class A >
void rw_hashmultimap< K, V, Hash, EQ, A >::clear ( void )
inline

Removes all items in the container.

◆ count()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::size_type rw_hashmultimap< K, V, Hash, EQ, A >::count ( const key_type & key) const
inline

Returns the number of items in self whose key compares equal to key according to the associated equality function object.

◆ empty()

template<class K , class V , class Hash , class EQ , class A >
bool rw_hashmultimap< K, V, Hash, EQ, A >::empty ( void ) const
inline

Returns true if there are no items in the container.

◆ end() [1/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::end ( void )
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

◆ end() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::end ( void ) const
inline

Returns an iterator referring to the element after the last element in the container.

Dereferencing the iterator returned by this function results in undefined behavior.

◆ equal_by_keys()

template<class K , class V , class Hash , class EQ , class A >
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 the container and rhs have the same number of elements, and for each value_type in lhs, there is a value_type in rhs that has a first part (the key) for which the equality function object returns true. The second part (the value) of the pair is not compared.

◆ equal_range() [1/2]

template<class K , class V , class Hash , class EQ , class A >
std::pair< typename rw_hashmultimap< K, V, Hash, EQ, A >::iterator, typename rw_hashmultimap< K, V, Hash, EQ, A >::iterator > rw_hashmultimap< K, V, Hash, EQ, A >::equal_range ( const key_type & key)
inline

Returns the bounds of the subrange representing all values in the container whose key compares equal to key according to the associated equality function object. If no items in the container compare equal to key, returns end() for both iterators.

◆ equal_range() [2/2]

template<class K , class V , class Hash , class EQ , class A >
std::pair< typename rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator, typename rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator > rw_hashmultimap< K, V, Hash, EQ, A >::equal_range ( const key_type & key) const
inline

Returns the bounds of the subrange representing all values in the container whose key compares equal to key according to the associated equality function object. If no items in the container compare equal to key, returns end() for both iterators.

◆ erase() [1/3]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::size_type rw_hashmultimap< K, V, Hash, EQ, A >::erase ( const key_type & key)
inline

Removes each item in the container that compares equal to key according to the equality function object. Returns the number of items that were removed.

◆ erase() [2/3]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::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.

◆ erase() [3/3]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::erase ( iterator iter,
iterator bound )
inline

Removes each element in the range [first, last). Returns an iterator referencing last. If first does not reference an item in self (and if first and last are not equal), the behavior is undefined.

◆ fill_ratio()

template<class K , class V , class Hash , class EQ , class A >
float rw_hashmultimap< K, V, Hash, EQ, A >::fill_ratio ( void ) const
inline

Returns the ratio of the number of items in the container to the number of buckets.

◆ find() [1/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::find ( const key_type & key)
inline

Returns the first item in self whose key compares equal to key according to the associated equality function object. If no items in the container compare equal to key, returns end().

◆ find() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::find ( const key_type & key) const
inline

Returns the first item in self whose key compares equal to key according to the associated equality function object. If no items in the container compare equal to key, returns end().

◆ insert() [1/5]

template<class K , class V , class Hash , class EQ , class A >
std::pair< typename rw_hashmultimap< K, V, Hash, EQ, A >::iterator, bool > rw_hashmultimap< K, V, Hash, EQ, A >::insert ( const value_type & val)
inline

Inserts a copy of val into the container. Returns an iterator to the new item, along with the status true.

◆ insert() [2/5]

template<class K , class V , class Hash , class EQ , class A >
template<typename InputIterator >
rw_hashmultimap< K, V, Hash, EQ, A >::size_type rw_hashmultimap< K, V, Hash, EQ, A >::insert ( InputIterator first,
InputIterator last )
inline

For each value in the range [first, last), inserts a copy of the value into self. Returns the number of elements inserted.

InputIterator is an input iterator type that points to elements that are convertible to value_type objects.

Note
first and last must not be iterators into self.

◆ insert() [3/5]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::insert ( iterator hint,
const value_type & val )
inline

Inserts a copy of val into the container. Returns an iterator to the new item, along with the status true.

The parameter hint is ignored.

◆ insert() [4/5]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::insert ( iterator hint,
value_type && val )
inline

Inserts val into the container. Returns an iterator to the new item, along with the status true.

The parameter hint is ignored.

Condition:
This method is available only on platforms with rvalue reference support.

◆ insert() [5/5]

template<class K , class V , class Hash , class EQ , class A >
std::pair< typename rw_hashmultimap< K, V, Hash, EQ, A >::iterator, bool > rw_hashmultimap< K, V, Hash, EQ, A >::insert ( value_type && val)
inline

Inserts val into the container. Returns an iterator to the new item, along with the status true.

Condition:
This method is available only on platforms with rvalue reference support.

◆ lower_bound() [1/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::lower_bound ( const key_type & key)
inline

Equivalent to equal_range(key).first.

◆ lower_bound() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::lower_bound ( const key_type & key) const
inline

Equivalent to equal_range(key).first.

◆ operator=() [1/2]

template<class K , class V , class Hash , class EQ , class A >
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

Replaces the contents of self with copies of the contents of rhs. The capacity, hash function object and equality function object are replaced by the respective objects from rhs.

◆ operator=() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A > & rw_hashmultimap< K, V, Hash, EQ, A >::operator= ( rw_hashmultimap< K, V, Hash, EQ, A > && rhs)
inline

Replaces the contents of self with the contents moved from rhs. The capacity, hash function object and equality function objects are moved from the respective objects in rhs.

Condition:
This method is available only on platforms with rvalue reference support.

◆ resize()

template<class K , class V , class Hash , class EQ , class A >
void rw_hashmultimap< K, V, Hash, EQ, A >::resize ( size_t cap)
inline

Sets the number of buckets to cap. Each item in the container is rehashed according to the new number of buckets.

Note
If cap is 0, it is ignored.

◆ size()

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::size_type rw_hashmultimap< K, V, Hash, EQ, A >::size ( void ) const
inline

Returns the number of items in the container.

◆ swap()

template<class K , class V , class Hash , class EQ , class A >
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.

◆ upper_bound() [1/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::iterator rw_hashmultimap< K, V, Hash, EQ, A >::upper_bound ( const key_type & key)
inline

Equivalent to equal_range(key).second.

◆ upper_bound() [2/2]

template<class K , class V , class Hash , class EQ , class A >
rw_hashmultimap< K, V, Hash, EQ, A >::const_iterator rw_hashmultimap< K, V, Hash, EQ, A >::upper_bound ( const key_type & key) const
inline

Equivalent to equal_range(key).second.

Friends And Related Symbol Documentation

◆ operator!=()

template<class K , class V , class Hash , class EQ , class A >
bool operator!= ( const rw_hashmultimap< K, V, Hash, EQ, A > & lhs,
const rw_hashmultimap< K, V, Hash, EQ, A > & rhs )
related

Equivalent to !(lhs == rhs).

◆ operator==()

template<class K , class V , class Hash , class EQ , class A >
bool operator== ( const rw_hashmultimap< K, V, Hash, EQ, A > & lhs,
const rw_hashmultimap< K, V, Hash, EQ, A > & rhs )
related

Returns true if lhs and rhs have the same number of elements, and for each item in lhs, there is an item in rhs whose first part (the key) compares equal according to the equality function object and whose second part (the value) compares equal according to operator==().

Note
If only the keys of the values need to be compared for equality, use rw_hashmultimap::equal_by_keys() instead.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.