|
AGX Dynamics
2.35.0.1
|
A cache-friendly hash table with open addressing, linear probing and power-of-two capacity. More...
#include <LinearProbingHashTable.h>
Inheritance diagram for agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >:Classes | |
| class | const_iterator |
| class | insert_iterator |
| class | iterator |
Public Types | |
| using | bucket_type = PairT |
| enum | ClearPolicy { SHRINK_BUFFER , SHRINK_BUFFER_AVERAGED , MAINTAIN_BUFFER } |
| using | const_reference = const PairT & |
| using | key_type = KeyT |
| using | reference = PairT & |
| using | size_type = size_t |
| using | value_type = ValueT |
Public Member Functions | |
| LinearProbingHashTableImplementation ()=default | |
| LinearProbingHashTableImplementation (const LinearProbingHashTableImplementation &other) | |
| LinearProbingHashTableImplementation (LinearProbingHashTableImplementation &&other) | |
| ~LinearProbingHashTableImplementation () | |
| iterator | begin () |
| Iterator to first element in hash table. More... | |
| const_iterator | begin () const |
| Iterator to first element in hash table. More... | |
| size_t | capacity () const |
| void | clear (int=0) |
| Remove all elements, keeping full capacity. More... | |
| bool | contains (const KeyT &k) const |
| Check if the hash table contains a key/value pair for the given key. More... | |
| size_t | count (const KeyT &k) const |
| Count the number of key/value pairs matching the given key. More... | |
| bool | empty () const |
| iterator | end () |
| Iterator marking end of hash table. More... | |
| const_iterator | end () const |
| Iterator marking end of hash table. More... | |
| bool | erase (const KeyT &key) |
| Erase an element from the hash table. More... | |
| iterator | erase (iterator it) |
| Erase an element from the hash table. More... | |
| iterator | find (const KeyT &key) |
| Find a key/value pair in the hash table given a key. More... | |
| const_iterator | find (const KeyT &key) const |
| Find a key/value pair in the hash table given a key. More... | |
| const ValueT | get_or_return_default (const KeyT &k) const |
| insert_iterator | insert (const KeyT &key, const ValueT value) |
| Insert a key/value pair into the hash table. More... | |
| insert_iterator | insert (const std::pair< KeyT, ValueT > &p) |
| void | insert (const_iterator begin, const_iterator end) |
| Insert all elements in the given range. More... | |
| void | insert_unique (KeyT &&key, ValueT &&value) |
| Insert a key/value pair into the hash table assuming that the given key does not already exist in the hash table. More... | |
| void | insert_unique (std::pair< KeyT, ValueT > &&p) |
| LinearProbingHashTableImplementation & | operator= (const LinearProbingHashTableImplementation &other) |
| LinearProbingHashTableImplementation & | operator= (LinearProbingHashTableImplementation &&other) |
| ValueT & | operator[] (const KeyT &key) |
| Return the value associated with the given key. More... | |
| const void * | ptr () const |
| void | reserve (size_t num_elems) |
| Make room for this many elements in the hash table. More... | |
| ValueT | set_get (const KeyT &key, const ValueT &new_value) |
| size_t | size () const |
| void | swap (LinearProbingHashTableImplementation &other) |
| ValueT * | try_get (const KeyT &k) |
| Find the value associated with the given key. More... | |
| const ValueT * | try_get (const KeyT &k) const |
| Find the value associated with the given key. More... | |
Protected Member Functions | |
| void | erase_bucket (size_t bucket) |
| template<typename T2 > | |
| size_t | find_filled_bucket (const T2 &key) const |
A cache-friendly hash table with open addressing, linear probing and power-of-two capacity.
Definition at line 47 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::bucket_type = PairT |
Definition at line 64 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::const_reference = const PairT& |
Definition at line 66 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::key_type = KeyT |
Definition at line 61 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reference = PairT& |
Definition at line 65 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::size_type = size_t |
Definition at line 62 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::value_type = ValueT |
Definition at line 63 of file LinearProbingHashTable.h.
| enum agx::LinearProbingHashTableImplementation::ClearPolicy |
Definition at line 73 of file LinearProbingHashTable.h.
|
default |
|
inline |
Definition at line 306 of file LinearProbingHashTable.h.
References agx::cbegin(), agx::cend(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reserve(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::size().
|
inline |
Definition at line 312 of file LinearProbingHashTable.h.
|
inline |
Definition at line 331 of file LinearProbingHashTable.h.
|
inline |
Iterator to first element in hash table.
Definition at line 360 of file LinearProbingHashTable.h.
Referenced by agx::begin(), agx::cbegin(), agxData::Type::getFormat(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert().
|
inline |
Iterator to first element in hash table.
Definition at line 372 of file LinearProbingHashTable.h.
|
inline |
Definition at line 406 of file LinearProbingHashTable.h.
|
inline |
Remove all elements, keeping full capacity.
Definition at line 656 of file LinearProbingHashTable.h.
Referenced by agx::HashVector< KeyT, DataT, HashT >::clear(), agx::SetVector< DataT, HashT >::clear(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::operator=(), agx::HashVector< KeyT, DataT, HashT >::purge(), and agx::SetVector< DataT, HashT >::purge().
|
inline |
Check if the hash table contains a key/value pair for the given key.
| k | Key to look for. |
Definition at line 455 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
Referenced by agx::HashVector< KeyT, DataT, HashT >::contains(), agx::SetVector< DataT, HashT >::contains(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert_unique().
|
inline |
Count the number of key/value pairs matching the given key.
Will always be either 0 or 1.
| k | The key to count. |
Definition at line 466 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
|
inline |
Definition at line 414 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
|
inline |
Iterator marking end of hash table.
Definition at line 385 of file LinearProbingHashTable.h.
Referenced by agx::cend(), agx::end(), agx::HashVector< KeyT, DataT, HashT >::erase(), agx::SetVector< DataT, HashT >::erase(), agx::HashVector< KeyT, DataT, HashT >::find(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find(), agx::SetVector< DataT, HashT >::find(), agxData::Type::getFormat(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::HashVector< KeyT, DataT, HashT >::push_back(), agx::SetVector< DataT, HashT >::push_back(), agxData::Format::registerFormatPrimitives(), agx::HashVector< KeyT, DataT, HashT >::replace(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Iterator marking end of hash table.
Definition at line 392 of file LinearProbingHashTable.h.
|
inline |
Erase an element from the hash table.
Definition at line 630 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase_bucket(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
Referenced by agx::HashVector< KeyT, DataT, HashT >::replace(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Erase an element from the hash table.
Definition at line 645 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::iterator::_bucket, agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::iterator::_map, agxAssert, and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase_bucket().
|
inlineprotected |
Definition at line 754 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase().
|
inline |
Find a key/value pair in the hash table given a key.
| key | The key to look for. |
Definition at line 426 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
Referenced by agx::HashVector< KeyT, DataT, HashT >::erase(), agx::SetVector< DataT, HashT >::erase(), agx::HashVector< KeyT, DataT, HashT >::find(), agx::SetVector< DataT, HashT >::find(), agxData::Type::getFormat(), agx::HashVector< KeyT, DataT, HashT >::push_back(), agx::SetVector< DataT, HashT >::push_back(), agxData::Format::registerFormatPrimitives(), agx::HashVector< KeyT, DataT, HashT >::replace(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Find a key/value pair in the hash table given a key.
| key | The key to look for. |
Definition at line 440 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
|
inlineprotected |
Definition at line 737 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::empty(), and agx::hashKeyEqual().
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::contains(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::count(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::try_get().
|
inline |
Definition at line 502 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::try_get().
Referenced by agxVehicle::Track::getWheel().
|
inline |
Insert a key/value pair into the hash table.
The current value is overwritten if a key/value pair with an equal key already exists.
| key | The key to insert. |
| value | The value to associate with the given key. |
Definition at line 521 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::LinearProbingHashTableImplementation(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::operator=(), agx::HashVector< KeyT, DataT, HashT >::purge(), agx::SetVector< DataT, HashT >::purge(), agx::HashVector< KeyT, DataT, HashT >::push_back(), agx::SetVector< DataT, HashT >::push_back(), agxData::Format::registerFormatPrimitives(), agx::HashVector< KeyT, DataT, HashT >::replace(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Definition at line 540 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert().
|
inline |
Insert all elements in the given range.
| begin | Beginning of the range. |
| end | End of the range. |
Definition at line 551 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::begin(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::end(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert().
|
inline |
Insert a key/value pair into the hash table assuming that the given key does not already exist in the hash table.
It is undefined behavior to call this method with a key that does already exist in the hash table.
| key | The key to insert. |
| value | The value to associate with the key. |
Definition at line 566 of file LinearProbingHashTable.h.
References agxAssert, and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::contains().
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert_unique().
|
inline |
Definition at line 576 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert_unique().
|
inline |
Definition at line 317 of file LinearProbingHashTable.h.
References agx::cbegin(), agx::cend(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clear(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reserve(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::size().
|
inline |
Definition at line 325 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::swap().
|
inline |
Return the value associated with the given key.
A new value is default created, inserted and then returned if the given key does not yet exist in the hash table.
| key | The key to find. |
Definition at line 608 of file LinearProbingHashTable.h.
|
inline |
Definition at line 729 of file LinearProbingHashTable.h.
|
inline |
Make room for this many elements in the hash table.
Definition at line 671 of file LinearProbingHashTable.h.
References agxAssert.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::LinearProbingHashTableImplementation(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::operator=(), agx::HashVector< KeyT, DataT, HashT >::purge(), agx::SetVector< DataT, HashT >::purge(), agx::HashVector< KeyT, DataT, HashT >::reserve(), and agx::SetVector< DataT, HashT >::reserve().
|
inline |
Definition at line 582 of file LinearProbingHashTable.h.
|
inline |
Definition at line 398 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::LinearProbingHashTableImplementation(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::operator=().
|
inline |
Definition at line 343 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::operator=().
|
inline |
Find the value associated with the given key.
Returns nullptr if no such value exists.
| k | The key to look for. |
Definition at line 476 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::get_or_return_default().
|
inline |
Find the value associated with the given key.
Returns nullptr if no such value exists.
| k | The key to look for. |
Definition at line 491 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().