|
roo_collections
API Documentation for roo_collections
|
Flat, memory-conscious hash table optimized for small collections. More...
#include <flat_small_hashtable.h>
Data Structures | |
| class | ConstIterator |
| Constant forward iterator. More... | |
| class | Iterator |
| Mutable forward iterator. More... | |
Public Types | |
| using | key_type = Key |
| using | value_type = Entry |
| using | hasher = HashFn |
| using | key_equal = KeyCmpFn |
| using | iterator = Iterator |
| using | const_iterator = ConstIterator |
Public Member Functions | |
| template<typename InputIt > | |
| FlatSmallHashtable (InputIt first, InputIt last, HashFn hash_fn=HashFn(), KeyFn key_fn=KeyFn(), KeyCmpFn key_cmp_fn=KeyCmpFn()) | |
| Constructs a table from an iterator range. | |
| FlatSmallHashtable (std::initializer_list< Entry > init, HashFn hash_fn=HashFn(), KeyFn key_fn=KeyFn(), KeyCmpFn key_cmp_fn=KeyCmpFn()) | |
| Constructs a table from an initializer list. | |
| FlatSmallHashtable (HashFn hash_fn=HashFn(), KeyFn key_fn=KeyFn(), KeyCmpFn key_cmp_fn=KeyCmpFn()) | |
| Constructs an empty table with default initial capacity. | |
| FlatSmallHashtable (uint16_t size_hint, HashFn hash_fn=HashFn(), KeyFn key_fn=KeyFn(), KeyCmpFn key_cmp_fn=KeyCmpFn()) | |
Constructs an empty table sized for size_hint elements. | |
| FlatSmallHashtable (FlatSmallHashtable &&other) | |
| Move constructor. | |
| FlatSmallHashtable (const FlatSmallHashtable &other) | |
| Copy constructor. | |
| ~FlatSmallHashtable () | |
| Destructor. | |
| FlatSmallHashtable & | operator= (FlatSmallHashtable &&other) |
| Move assignment. | |
| FlatSmallHashtable & | operator= (const FlatSmallHashtable &other) |
| Copy assignment. | |
| bool | operator== (const FlatSmallHashtable &other) const |
| Equality comparison by key/value content. | |
| bool | operator!= (const FlatSmallHashtable &other) |
| uint16_t | ht_len () const |
| Returns the internal bucket array length. | |
| ConstIterator | begin () const |
| Returns an iterator to the first element. | |
| Iterator | begin () |
| Returns a mutable iterator to the first element. | |
| Iterator | end () |
| Returns iterator past the end. | |
| ConstIterator | end () const |
| Returns const iterator past the end. | |
| uint16_t | size () const |
| Returns the number of stored elements. | |
| bool | empty () const |
| Returns whether the table is empty. | |
| uint16_t | capacity () const |
| Returns the number of elements insertable before rehashing. | |
| ConstIterator | find (const Key &key) const |
Finds key and returns a const iterator to the matching entry. | |
| template<typename K , typename = has_is_transparent_t<HashFn, K>, typename = has_is_transparent_t<KeyCmpFn, K>> | |
| ConstIterator | find (const K &key) const |
Heterogeneous lookup overload of find. | |
| bool | erase (const Key &key) |
| Removes an entry by key. | |
| template<typename K , typename = has_is_transparent_t<HashFn, K>, typename = has_is_transparent_t<KeyCmpFn, K>> | |
| bool | erase (const K &key) |
Heterogeneous key overload of erase. | |
| Iterator | erase (const ConstIterator &itr) |
Removes the entry at itr and returns iterator to the next entry. | |
| void | clear () |
| Removes all entries while preserving current allocated capacity. | |
| void | compact () |
| Rebuilds the table to remove tombstones and shrink capacity. | |
| bool | contains (const Key &key) const |
Returns whether key exists in the table. | |
| template<typename K , typename = has_is_transparent_t<HashFn, K>, typename = has_is_transparent_t<KeyCmpFn, K>> | |
| bool | contains (const K &key) const |
Heterogeneous key overload of contains. | |
| std::pair< Iterator, bool > | insert (Entry val) |
Inserts val if key is not present. | |
Protected Member Functions | |
| Iterator | lookup (const Key &key) |
| template<typename K , typename = has_is_transparent_t<HashFn, K>, typename = has_is_transparent_t<KeyCmpFn, K>> | |
| Iterator | lookup (const K &key) |
Friends | |
| class | ConstIterator |
| class | Iterator |
Flat, memory-conscious hash table optimized for small collections.
Uses open addressing with quadratic probing and stores entries in contiguous arrays for low overhead. Maximum supported size is approximately 64k elements.
| Entry | Stored entry type. |
| Key | Key type used for lookup. |
| HashFn | Hash function. |
| KeyFn | Extracts a key from an entry. |
| KeyCmpFn | Key equality predicate. |
Definition at line 182 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::const_iterator = ConstIterator |
Definition at line 286 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::hasher = HashFn |
Definition at line 283 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::iterator = Iterator |
Definition at line 285 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::key_equal = KeyCmpFn |
Definition at line 284 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::key_type = Key |
Definition at line 281 of file flat_small_hashtable.h.
| using roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::value_type = Entry |
Definition at line 282 of file flat_small_hashtable.h.
|
inline |
Constructs a table from an iterator range.
Definition at line 290 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert().
|
inline |
Constructs a table from an initializer list.
Definition at line 300 of file flat_small_hashtable.h.
|
inline |
Constructs an empty table with default initial capacity.
Definition at line 307 of file flat_small_hashtable.h.
|
inline |
Constructs an empty table sized for size_hint elements.
| size_hint | Expected number of items. |
Definition at line 313 of file flat_small_hashtable.h.
References roo_collections::kRadkePrimes.
|
inline |
Move constructor.
Definition at line 334 of file flat_small_hashtable.h.
|
inline |
Copy constructor.
Definition at line 352 of file flat_small_hashtable.h.
References roo_collections::kRadkePrimes.
|
inline |
Destructor.
Definition at line 373 of file flat_small_hashtable.h.
|
inline |
Returns a mutable iterator to the first element.
Definition at line 462 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Returns an iterator to the first element.
Definition at line 452 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Returns the number of elements insertable before rehashing.
Definition at line 484 of file flat_small_hashtable.h.
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert().
|
inline |
Removes all entries while preserving current allocated capacity.
Definition at line 628 of file flat_small_hashtable.h.
References roo_collections::kRadkePrimes.
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert().
|
inline |
Rebuilds the table to remove tombstones and shrink capacity.
Definition at line 641 of file flat_small_hashtable.h.
References roo_collections::initialCapacityIdx(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::size().
|
inline |
Heterogeneous key overload of contains.
Definition at line 659 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Returns whether key exists in the table.
Definition at line 654 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Returns whether the table is empty.
Definition at line 481 of file flat_small_hashtable.h.
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert().
|
inline |
Returns iterator past the end.
Definition at line 472 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
Referenced by roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::erase(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::lookup(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::lookup(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[](), and roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[]().
|
inline |
Returns const iterator past the end.
Definition at line 475 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Removes the entry at itr and returns iterator to the next entry.
Definition at line 619 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::erase().
|
inline |
Heterogeneous key overload of erase.
true if an entry was removed. Definition at line 587 of file flat_small_hashtable.h.
References roo_collections::fastmod(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Removes an entry by key.
true if an entry was removed. Definition at line 544 of file flat_small_hashtable.h.
References roo_collections::fastmod(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::erase().
|
inline |
Heterogeneous lookup overload of find.
end() when not found. Definition at line 517 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::fastmod(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
|
inline |
Finds key and returns a const iterator to the matching entry.
end() when not found. Definition at line 488 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::fastmod(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::contains(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::contains(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::find(), and roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::find().
|
inline |
Returns the internal bucket array length.
Definition at line 449 of file flat_small_hashtable.h.
References roo_collections::kRadkePrimes.
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::begin(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::begin(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::contains(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::contains(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::erase(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::erase(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::lookup(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::lookup(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ConstIterator::operator++(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::Iterator::operator++().
|
inline |
Inserts val if key is not present.
Definition at line 665 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::capacity(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::clear(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::empty(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::fastmod(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len(), roo_collections::kRadkePrimes, roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::lookup(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::size().
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::FlatSmallHashtable(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[](), and roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[]().
|
inlineprotected |
|
inlineprotected |
Definition at line 740 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::end(), roo_collections::fastmod(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::ht_len().
Referenced by roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::at(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::find(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert(), roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[](), and roo_collections::FlatSmallHashMap< Key, Value, HashFn, KeyCmpFn >::operator[]().
|
inline |
Definition at line 446 of file flat_small_hashtable.h.
|
inline |
Copy assignment.
Definition at line 407 of file flat_small_hashtable.h.
References roo_collections::kRadkePrimes.
|
inline |
Move assignment.
Definition at line 379 of file flat_small_hashtable.h.
|
inline |
Equality comparison by key/value content.
Definition at line 433 of file flat_small_hashtable.h.
References roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::size().
|
inline |
Returns the number of stored elements.
Definition at line 478 of file flat_small_hashtable.h.
Referenced by roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::compact(), roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::insert(), and roo_collections::FlatSmallHashtable< Entry, Key, HashFn, KeyFn, KeyCmpFn >::operator==().
|
friend |
Definition at line 798 of file flat_small_hashtable.h.
|
friend |
Definition at line 799 of file flat_small_hashtable.h.