A cache-friendly hash table with open addressing, linear probing and power-of-two capacity.
More...
#include <HashContainers.hpp>
|
using | size_type = size_t |
|
using | value_type = PairT |
|
using | reference = PairT & |
|
using | const_reference = const PairT & |
|
|
| HashMap (const HashMap &other) |
|
| HashMap (HashMap &&other) |
|
HashMap & | operator= (const HashMap &other) |
|
void | operator= (HashMap &&other) |
|
void | swap (HashMap &other) |
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
size_t | size () const |
|
bool | empty () const |
|
iterator | find (const KeyT &key) |
|
const_iterator | find (const KeyT &key) const |
|
bool | contains (const KeyT &k) const |
|
size_t | count (const KeyT &k) const |
|
ValueT * | try_get (const KeyT &k) |
| Returns the matching ValueT or nullptr if k isn't found.
|
|
const ValueT * | try_get (const KeyT &k) const |
| Const version of the above.
|
|
const ValueT | get_or_return_default (const KeyT &k) const |
| Convenience function.
|
|
std::pair< iterator, bool > | insert (const KeyT &key, const ValueT &value) |
|
std::pair< iterator, bool > | insert (const std::pair< KeyT, ValueT > &p) |
|
void | insert (const_iterator begin, const_iterator end) |
|
void | insert_unique (KeyT &&key, ValueT &&value) |
| Same as above, but contains(key) MUST be false.
|
|
void | insert_unique (std::pair< KeyT, ValueT > &&p) |
|
ValueT | set_get (const KeyT &key, const ValueT &new_value) |
| Return the old value or ValueT() if it didn't exist.
|
|
ValueT & | operator[] (const KeyT &key) |
| Like std::map<KeyT,ValueT>::operator[].
|
|
bool | erase (const KeyT &key) |
|
iterator | erase (iterator it) |
|
void | clear () |
| Remove all elements, keeping full capacity.
|
|
void | reserve (size_t num_elems) |
| Make room for this many elements.
|
|
template<typename KeyT, typename ValueT, typename HashT = std::hash<KeyT>, typename CompT = HashMapEqualTo<KeyT>>
class emlib::HashMap< KeyT, ValueT, HashT, CompT >
A cache-friendly hash table with open addressing, linear probing and power-of-two capacity.
template<typename KeyT, typename ValueT, typename HashT = std::hash<KeyT>, typename CompT = HashMapEqualTo<KeyT>>
bool emlib::HashMap< KeyT, ValueT, HashT, CompT >::erase |
( |
const KeyT & |
key | ) |
|
|
inline |
Erase an element from the hash table. return false if element was not found
template<typename KeyT, typename ValueT, typename HashT = std::hash<KeyT>, typename CompT = HashMapEqualTo<KeyT>>
Erase an element using an iterator. Returns an iterator to the next element (or end()).
template<typename KeyT, typename ValueT, typename HashT = std::hash<KeyT>, typename CompT = HashMapEqualTo<KeyT>>
std::pair<iterator, bool> emlib::HashMap< KeyT, ValueT, HashT, CompT >::insert |
( |
const KeyT & |
key, |
|
|
const ValueT & |
value |
|
) |
| |
|
inline |
Returns a pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.
The documentation for this class was generated from the following file: