|
AGX Dynamics 2.42.3.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 | 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. | |
| const_iterator | begin () const |
| Iterator to first element in hash table. | |
| size_t | capacity () const |
| void | clear (int policy=SHRINK_BUFFER_AVERAGED) |
| Remove all elements. | |
| void | clearResize (size_t num_elems) |
| Resize the table to fit at least num_elems elements and clear all existing entries. | |
| bool | contains (const KeyT &k) const |
| Check if the hash table contains a key/value pair for the given key. | |
| size_t | count (const KeyT &k) const |
| Count the number of key/value pairs matching the given key. | |
| bool | empty () const |
| iterator | end () |
| Iterator marking end of hash table. | |
| const_iterator | end () const |
| Iterator marking end of hash table. | |
| bool | erase (const KeyT &key) |
| Erase an element from the hash table. | |
| iterator | erase (iterator it) |
| Erase an element from the hash table. | |
| iterator | find (const KeyT &key) |
| Find a key/value pair in the hash table given a key. | |
| const_iterator | find (const KeyT &key) const |
| Find a key/value pair in the hash table given a key. | |
| const ValueT | get_or_return_default (const KeyT &k) const |
| iterator | insert (const KeyT &key, const ValueT value) |
| Insert a key/value pair into the hash table. | |
| iterator | insert (const std::pair< KeyT, ValueT > &p) |
| void | insert (const_iterator begin, const_iterator end) |
| Insert all elements in the given range. | |
| 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. | |
| 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. | |
| const void * | ptr () const |
| void | reserve (size_t num_elems) |
| Make room for this many elements in the hash table. | |
| 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. | |
| const ValueT * | try_get (const KeyT &k) const |
| Find the value associated with the given key. | |
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 48 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::bucket_type = PairT |
Definition at line 69 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::const_reference = const PairT& |
Definition at line 71 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::key_type = KeyT |
Definition at line 66 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::reference = PairT& |
Definition at line 70 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::size_type = size_t |
Definition at line 67 of file LinearProbingHashTable.h.
| using agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::value_type = ValueT |
Definition at line 68 of file LinearProbingHashTable.h.
| enum agx::LinearProbingHashTableImplementation::ClearPolicy |
Definition at line 78 of file LinearProbingHashTable.h.
|
default |
|
inline |
Definition at line 287 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 293 of file LinearProbingHashTable.h.
|
inline |
Definition at line 316 of file LinearProbingHashTable.h.
|
inline |
Iterator to first element in hash table.
Definition at line 345 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 357 of file LinearProbingHashTable.h.
|
inline |
Definition at line 391 of file LinearProbingHashTable.h.
|
inline |
Remove all elements.
Definition at line 638 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clearResize(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::empty(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::MAINTAIN_BUFFER, and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::SHRINK_BUFFER.
Referenced by agx::ReferencedHandler::clear(), 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 |
Resize the table to fit at least num_elems elements and clear all existing entries.
Definition at line 744 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clear().
|
inline |
Check if the hash table contains a key/value pair for the given key.
| k | Key to look for. |
Definition at line 440 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
Referenced by agx::ReferencedHandler::contains(), agx::HashVector< KeyT, DataT, HashT >::contains(), agx::SetVector< DataT, HashT >::contains(), agxModel::DMeshRegistry::hasCustomStorage(), 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 451 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
|
inline |
Definition at line 399 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::clear(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().
|
inline |
Iterator marking end of hash table.
Definition at line 370 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::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find(), agx::SetVector< DataT, HashT >::find(), agxModel::DMeshRegistry::getCustomStorage(), 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 377 of file LinearProbingHashTable.h.
|
inline |
Erase an element from the hash table.
Definition at line 612 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::ReferencedHandler::clear(), agx::ReferencedHandler::remove(), agx::HashVector< KeyT, DataT, HashT >::replace(), and agx::SetVector< DataT, HashT >::replace().
|
inline |
Erase an element from the hash table.
Definition at line 627 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 808 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase(), and agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, 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 411 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(), agxModel::DMeshRegistry::getCustomStorage(), 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 425 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 791 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::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::contains(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::count(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::erase(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::erase(), agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find(), and agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::try_get().
|
inline |
Definition at line 487 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 506 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::LinearProbingHashTableImplementation(), agxModel::DMeshRegistry::getCustomStorage(), 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 522 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 533 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 548 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 558 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::insert_unique().
|
inline |
Definition at line 298 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 310 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 590 of file LinearProbingHashTable.h.
|
inline |
Definition at line 783 of file LinearProbingHashTable.h.
|
inline |
Make room for this many elements in the hash table.
Definition at line 686 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 564 of file LinearProbingHashTable.h.
|
inline |
Definition at line 383 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 328 of file LinearProbingHashTable.h.
References std::swap().
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 461 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 476 of file LinearProbingHashTable.h.
References agx::LinearProbingHashTableImplementation< KeyT, ValueT, HashT, AllocatorT >::find_filled_bucket().