|
AGX Dynamics
2.37.2.0
|
A cache-friendly hash table with open addressing, linear probing and power-of-two capacity. More...
#include <LinearProbingHashTable.h>
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. More... | |
| const_iterator | begin () const |
| Iterator to first element in hash table. More... | |
| size_t | capacity () const |
| void | clear (int policy=SHRINK_BUFFER_AVERAGED) |
| Remove all elements. More... | |
| void | clearResize (size_t num_elems) |
| Resize the table to fit at least num_elems elements and clear all existing entries. 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 |
| iterator | insert (const KeyT &key, const ValueT value) |
| Insert a key/value pair into the hash table. More... | |
| 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 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.
|
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(), and agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::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.
Referenced by agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::clear(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::clear(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::operator=(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::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< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::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.
Referenced by agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::contains(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::contains(), and agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::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.
|
inline |
Definition at line 399 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::clear(), and agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::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< agx::UInt32, agx::ref_ptr< RenderProxy > >::erase(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::erase(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::find(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::find(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::find(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::insert(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::push_back(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::replace(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::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.
Referenced by agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::replace(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::replace().
|
inline |
Erase an element from the hash table.
Definition at line 627 of file LinearProbingHashTable.h.
|
inlineprotected |
|
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.
Referenced by agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::erase(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::erase(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::find(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::find(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::push_back(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::replace(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::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.
|
inlineprotected |
Definition at line 791 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::contains(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::contains(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::count(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::erase(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::erase(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::find(), agx::LinearProbingHashTable< agx::ref_ptr< KeyT >, DataT, HashT, AllocatorT >::find(), and agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::try_get().
|
inline |
Definition at line 487 of file LinearProbingHashTable.h.
|
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< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::insert(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::LinearProbingHashTableImplementation(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::operator=(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::push_back(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::replace(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::replace().
|
inline |
Definition at line 522 of file LinearProbingHashTable.h.
|
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.
|
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.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::insert_unique().
|
inline |
Definition at line 558 of file LinearProbingHashTable.h.
|
inline |
Definition at line 298 of file LinearProbingHashTable.h.
|
inline |
Definition at line 310 of file LinearProbingHashTable.h.
|
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.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::erase_bucket(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::LinearProbingHashTableImplementation(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::operator=(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::reserve(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::reserve().
|
inline |
Definition at line 564 of file LinearProbingHashTable.h.
|
inline |
Definition at line 383 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::LinearProbingHashTableImplementation(), agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::operator=(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), and agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge().
|
inline |
Definition at line 328 of file LinearProbingHashTable.h.
Referenced by agx::LinearProbingHashTableImplementation< agx::Name, ref_ptr< Value >, agx::HashFn< agx::Name >, ByteAllocator >::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.
|
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.