rwlogo
SourcePro C++ 13.0

SourcePro® C++ API Reference Guide

Product Documentation:

   SourcePro C++
Documentation Home

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members | Public Types | Public Member Functions | Related Functions
rw_hashmap< 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<K,V> instances. More...

#include <rw/stdex/hashmap.h>

Public Types

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

Public Member Functions

 rw_hashmap (size_type sz=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type())
 
 rw_hashmap (const rw_hashmap< K, V, Hash, EQ, A > &map)
 
 rw_hashmap (rw_hashmap< K, V, Hash, EQ, A > &&lst)
 
template<typename InputIterator >
 rw_hashmap (InputIterator first, InputIterator last, size_type sz=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type())
 
 ~rw_hashmap ()
 
iterator begin ()
 
const_iterator begin () const
  More...
 
size_type capacity () const
 
const_iterator cbegin () const
  More...
 
const_iterator cend () const
  More...
 
void clear ()
 
size_type count (const key_type &key) const
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
  More...
 
bool equal_by_keys (const rw_hashmap< K, V, Hash, EQ, A > &rhs) 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 erase (const key_type &key)
 
iterator erase (iterator iter)
 
iterator erase (iterator iter, iterator bound)
 
float fill_ratio () const
 
const_iterator find (const key_type &key) const
 
iterator find (const key_type &key)
 
std::pair< iterator, bool > insert (const value_type &val)
 
iterator insert (iterator, const value_type &val)
 
std::pair< iterator, bool > insert (value_type &&val)
  More...
 
iterator insert (iterator, value_type &&val)
  More...
 
template<typename InputIterator >
size_type insert (InputIterator first, InputIterator last)
 
iterator lower_bound (const key_type &key)
 
const_iterator lower_bound (const key_type &key) const
  More...
 
rw_hashmap< K, V, Hash, EQ, A > & operator= (const rw_hashmap< K, V, Hash, EQ, A > &rhs)
 
rw_hashmap< K, V, Hash, EQ, A > & operator= (rw_hashmap< K, V, Hash, EQ, A > &&rhs)
 
V & operator[] (const key_type &key)
 
void resize (size_t sz)
 
size_type size () const
 
void swap (rw_hashmap< K, V, Hash, EQ, A > &other)
 
iterator upper_bound (const key_type &key)
 
const_iterator upper_bound (const key_type &key) const
  More...
 

Related Functions

(Note that these are not member functions.)

template<class K , class V , class Hash , class EQ , class A >
bool operator!= (const rw_hashmap< K, V, Hash, EQ, A > &lhs, const rw_hashmap< K, V, Hash, EQ, A > &rhs)
 
template<class K , class V , class Hash , class EQ , class A >
bool operator== (const rw_hashmap< K, V, Hash, EQ, A > &lhs, const rw_hashmap< 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_hashmap< K, V, Hash, EQ, A >

Class rw_hashmap<K,V,Hash,EQ,A> maintains a collection of mappings between K and V, implemented as a hash table of std::pair<const K,V>. operator== must be defined for type V. Pairs with duplicate keys are not allowed. Two pairs having duplicate keys as the result of the EQ comparison, applied to the first element of each, is true.

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,Hash,EQ,A> provides for iterators that reference its elements. Operations that alter the contents of rw_hashmap<K,V,Hash,EQ,A> may invalidate other iterators that reference the container. Since the contents of rw_hashmap<K,V,Hash,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().

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.

Note
Any two keys that are equivalent are disallowed for this container.

Synopsis

Persistence

None

Member Typedef Documentation

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 A rw_hashmap< K, V, Hash, EQ, A >::allocator_type

A type representing the allocator type for the container.

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::ConstIterator rw_hashmap< K, V, Hash, EQ, A >::const_iterator

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

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_hashmap< K, V, Hash, EQ, A >::const_pointer

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

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_hashmap< K, V, Hash, EQ, A >::const_reference

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

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_hashmap< K, V, Hash, EQ, A >::difference_type

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

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 Hash rw_hashmap< K, V, Hash, EQ, A >::hasher

A type representing the hash function.

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_hashmap< K, V, Hash, EQ, A >::iterator

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

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 EQ rw_hashmap< K, V, Hash, EQ, A >::key_equal_type

A type representing the equality function.

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 Hash rw_hashmap< K, V, Hash, EQ, A >::key_hash_type
Deprecated:
As of SourcePro 12.5, use hasher instead.

A type representing the hash function.

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 K rw_hashmap< K, V, Hash, EQ, A >::key_type

A type representing the key of the container.

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 V rw_hashmap< K, V, Hash, EQ, A >::mapped_type

A type representing the mapped value of the container.

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_hashmap< K, V, Hash, EQ, A >::pointer

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

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_hashmap< K, V, Hash, EQ, A >::reference

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

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_hashmap< K, V, Hash, EQ, A >::size_type

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

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 std::pair<const K,V> rw_hashmap< K, V, Hash, EQ, A >::value_type

A type representing the container's data type.

Constructor & Destructor Documentation

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap< K, V, Hash, EQ, A >::rw_hashmap ( size_type  sz = 64,
const hasher h = hasher(),
const key_equal_type eq = key_equal_type() 
)
inline

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

Note
If the value specified for sz is zero, the default number of slots is used.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap< K, V, Hash, EQ, A >::rw_hashmap ( const rw_hashmap< K, V, Hash, EQ, A > &  map)
inline

Constructs an rw_hashmap<K,V,Hash,EQ,A> that is a copy of map. Each element from map is copied into self.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap< K, V, Hash, EQ, A >::rw_hashmap ( rw_hashmap< K, V, Hash, EQ, A > &&  lst)
inline

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

Condition:
This method is only available on platforms with rvalue reference support.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
template<typename InputIterator >
rw_hashmap< K, V, Hash, EQ, A >::rw_hashmap ( InputIterator  first,
InputIterator  last,
size_type  sz = 64,
const hasher h = hasher(),
const key_equal_type eq = key_equal_type() 
)

Constructs an rw_hashmap<K,V,Hash,EQ,A> containing a copy of the pair elements in the range [first, last). The rw_hashmap instance has sz slots, uses h as its hash object, and eq as its equality comparator.

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

Note
If the value specified for sz is zero, the default number of slots is used.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap< K, V, Hash, EQ, A >::~rw_hashmap ( )
inline

Releases the memory used by the container's implementation.

Member Function Documentation

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::begin ( )
inline

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

If the container is empty, returns end().

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< K, V, Hash, EQ, A >::begin ( ) const
inline

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

If the container is empty, returns end().

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
size_type rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< K, V, Hash, EQ, A >::cbegin ( ) const
inline

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

If the container is empty, returns end().

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< K, V, Hash, EQ, A >::cend ( ) 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.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
void rw_hashmap< K, V, Hash, EQ, A >::clear ( )
inline

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

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
size_type rw_hashmap< K, V, Hash, EQ, A >::count ( const key_type key) const
inline

Returns 1 if self contains a pair with its first element EQ to key, else 0.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
bool rw_hashmap< K, V, Hash, EQ, A >::empty ( ) const
inline

Returns true if self is empty.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::end ( )
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.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< K, V, Hash, EQ, A >::end ( ) 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.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
bool rw_hashmap< K, V, Hash, EQ, A >::equal_by_keys ( const rw_hashmap< K, V, Hash, EQ, A > &  rhs) const
inline

Returns true if self and rhs have the same size, and if for each value_type in self, there is a value_type in rhs such that the EQ object in self returns true when called for the first parts of those pairs. 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
std::pair<iterator, iterator> rw_hashmap< 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.
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
std::pair<const_iterator, const_iterator> rw_hashmap< 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.
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
size_type rw_hashmap< K, V, Hash, EQ, A >::erase ( const key_type key)
inline

If there is a pair in self for which the first part is EQ to key, that pair is removed, and 1 is returned. Otherwise, 0 is returned.

Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::erase ( iterator  iter,
iterator  bound 
)
inline

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

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
float rw_hashmap< K, V, Hash, EQ, A >::fill_ratio ( ) const
inline

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

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< K, V, Hash, EQ, A >::find ( const key_type key) const
inline

Returns an rw_hashmap<K,V,Hash,EQ,A>::const_iterator referencing the pair with key as its first element if such a pair is contained in self, else returns end().

Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::find ( const key_type key)
inline

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

Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
std::pair<iterator, bool> rw_hashmap< K, V, Hash, EQ, A >::insert ( const value_type val)
inline

If there is no pair in self with first part EQ to the first part of val, inserts val, returning a pair with an iterator referencing the new element and true. Otherwise, returns a pair with an iterator referencing the matching value_type and false.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::insert ( iterator  ,
const value_type val 
)
inline

If there is no pair in self with first part EQ to the first part of val, inserts val, returning 1. Otherwise, does nothing and returns 0. 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
std::pair<iterator, bool> rw_hashmap< K, V, Hash, EQ, A >::insert ( value_type &&  val)
inline

If there is no pair in self with first part EQ to the first part of val, inserts val, returning a pair with an iterator referencing the new element and true. Otherwise, returns a pair with an iterator referencing the matching value_type and false.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< K, V, Hash, EQ, A >::insert ( iterator  ,
value_type &&  val 
)
inline

If there is no pair in self with first part EQ to the first part of val, inserts val, returning 1. Otherwise, does nothing and returns 0. 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
template<typename InputIterator >
size_type rw_hashmap< K, V, Hash, EQ, A >::insert ( InputIterator  first,
InputIterator  last 
)
inline

For each element in the range [first, last), inserts a copy of the element into self. If an element with the same key (according to EQ) already exists in self, the insertion is skipped. Returns the number of elements inserted.

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

Note
first and last must not be iterators into self.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< 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.
Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< 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.
Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap<K, V, Hash, EQ, A>& rw_hashmap< K, V, Hash, EQ, A >::operator= ( const rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
rw_hashmap<K, V, Hash, EQ, A>& rw_hashmap< K, V, Hash, EQ, A >::operator= ( rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
V& rw_hashmap< K, V, Hash, EQ, A >::operator[] ( const key_type key)

Returns a reference to the V part of a pair held in self which has a part EQ to key, either by finding such a pair, or inserting one (in which case the reference is to an instance of V created by its default constructor).

Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
void rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
size_type rw_hashmap< K, V, Hash, EQ, A >::size ( ) const
inline

Returns the number of pairs currently held in self.

template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
void rw_hashmap< K, V, Hash, EQ, A >::swap ( rw_hashmap< 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 = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
iterator rw_hashmap< 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.
Note
This method requires the type mapped_type to have a default constructor.
template<class K, class V, class Hash = RWTHash<K>, class EQ = std::equal_to<K>, class A = std::allocator< std::pair<const K,V> >>
const_iterator rw_hashmap< 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.
Note
This method requires the type mapped_type to have a default constructor.

Friends And Related Function Documentation

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

Equivalent to !(lhs == rhs).

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

Returns true if lhs 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 for which the EQ object in self returns true, and a second part for which operator==() returns true. The need to test both parts means that this operator is slightly slower than the method equal_by_keys().

Note
This method requires the type mapped_type to have a default constructor.

Copyright © 2014 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.
Provide feedback to Rogue Wave about its documentation.