|
| rw_hashmap (size_type cap=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type()) |
|
| rw_hashmap (const rw_hashmap &other) |
|
| rw_hashmap (rw_hashmap &&other) |
|
template<typename InputIterator > |
| rw_hashmap (InputIterator first, InputIterator last, size_type cap=64, const hasher &h=hasher(), const key_equal_type &eq=key_equal_type()) |
|
| ~rw_hashmap () |
|
iterator | begin () |
|
const_iterator | begin () const |
|
size_type | capacity () const |
|
const_iterator | cbegin () const |
|
const_iterator | cend () const |
|
void | clear () |
|
size_type | count (const key_type &key) const |
|
bool | empty () const |
|
iterator | end () |
|
const_iterator | end () const |
|
bool | equal_by_keys (const rw_hashmap &rhs) const |
|
std::pair< iterator, iterator > | equal_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 |
|
iterator | find (const key_type &key) |
|
const_iterator | find (const key_type &key) const |
|
std::pair< iterator, bool > | insert (const value_type &val) |
|
iterator | insert (iterator hint, const value_type &val) |
|
std::pair< iterator, bool > | insert (value_type &&val) |
|
iterator | insert (iterator, value_type &&val) |
|
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 |
|
rw_hashmap & | operator= (const rw_hashmap &rhs) |
|
rw_hashmap & | operator= (rw_hashmap &&rhs) |
|
mapped_type & | operator[] (const key_type &key) |
|
void | resize (size_t cap) |
|
size_type | size () const |
|
void | swap (rw_hashmap &other) |
|
iterator | upper_bound (const key_type &key) |
|
const_iterator | upper_bound (const key_type &key) const |
|
|
(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) |
|
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 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 not 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_hashmap 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
.
- Note
- Any two keys that are equivalent are disallowed for this container.
- Synopsis
#include <rw/stdex/hashmap.h>
- Persistence
- None
template<class K , class V , class Hash , class EQ , class A >
template<typename InputIterator >
Constructs an rw_hashmap containing a copy of the pair elements in the range [first, last). The rw_hashmap 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.
template<class K , class V , class Hash , class EQ , class A >
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 , class EQ , class A >
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 , class EQ , class A >
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 , class EQ , class A >
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 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.
template<class K , class V , class Hash , class EQ , class A >
Inserts a copy of val into the container. If an element in the container has the same key as val, an iterator to the existing element in the collection is returned with an associated status of false
. Otherwise, the value val is inserted into the collection and an iterator to the new item is returned, along with the status true
.
template<class K , class V , class Hash , class EQ , class A >
Inserts a copy of val into the container. If an element in the container has the same key as val, an iterator to the existing element in the collection is returned with an associated status of false
. Otherwise, the value val is inserted into the collection and an iterator to the new item is returned, along with the status true
.
The parameter hint is ignored.
template<class K , class V , class Hash , class EQ , class A >
Inserts val into the container. If an element in the container has the same key as val, an iterator to the existing element in the collection is returned with an associated status of false
. Otherwise, the value val is inserted into the collection and an iterator to the new item is returned, along with the status true
.
- Condition:
- This method is available only on platforms with rvalue reference support.
template<class K , class V , class Hash , class EQ , class A >
Inserts val into the container. If an element in the container has the same key as val, an iterator to the existing element in the collection is returned with an associated status of false
. Otherwise, the value val is inserted into the collection and an iterator to the new item is returned, along with the status true
.
The parameter hint is ignored.
- Condition:
- This method is available only on platforms with rvalue reference support.
template<class K , class V , class Hash , class EQ , class A >
template<typename InputIterator >
For each value in the range [first, last), inserts a copy of the value into self. If an element in the container has the same key as the value, the value is not inserted. 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.
template<class K , class V , class Hash , class EQ , class A >
Returns a reference to a mapped_type in the container whose key is equal to key according to the associated equality function object. If a key equal to key is not found in the collection, a default constructed mapped_type is created and inserted, and a reference to that instance is returned.
- Note
- This function requires that mapped_type is default constructible.
template<class K , class V , class Hash , class EQ , class A >
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 >
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 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_hashmap::equal_by_keys() instead.