Hash set with Robin Hood hashing for bounded probe distances and predictable performance.
More...
|
| | FastHashSet () |
| | Default constructor with initial capacity of 32 elements.
|
| | FastHashSet (std::initializer_list< TKey > init) |
| | Construct set from initializer_list.
|
| template<typename InputIt> |
| | FastHashSet (InputIt first, InputIt last) |
| | Construct set from iterator range.
|
| | FastHashSet (size_t initialCapacity) |
| | Constructor with specified initial capacity.
|
| | FastHashSet (FastHashSet &&other) noexcept |
| | Move constructor.
|
| FastHashSet & | operator= (FastHashSet &&other) noexcept |
| | Move assignment operator.
|
|
| FastHashSet (const FastHashSet &)=default |
| | Copy constructor.
|
| FastHashSet & | operator= (const FastHashSet &)=default |
| | Copy assignment operator.
|
|
| ~FastHashSet ()=default |
| | Destructor.
|
| template<typename KeyType = TKey> |
| const TKey * | find (const KeyType &key) const noexcept |
| | Fast lookup with heterogeneous key types (C++ idiom: pointer return).
|
| template<typename KeyType = TKey> |
| bool | contains (const KeyType &key) const noexcept |
| | Check if a key exists in the set.
|
| template<typename KeyType = TKey> |
| const TKey & | at (const KeyType &key) const |
| | Checked element access with bounds checking.
|
| bool | insert (const TKey &key) |
| | Insert a key into the set (copy semantics).
|
| bool | insert (TKey &&key) |
| | Insert a key into the set (move semantics).
|
| template<typename... Args> |
| bool | emplace (Args &&... args) |
| | Construct and insert a key in-place.
|
| template<typename... Args> |
| std::pair< Iterator, bool > | tryEmplace (Args &&... args) |
| | Try to emplace a key if it doesn't exist.
|
| void | reserve (size_t minCapacity) |
| | Reserve capacity for at least the specified number of elements.
|
| template<typename KeyType = TKey> |
| bool | erase (const KeyType &key) noexcept |
| | Remove a key from the set.
|
| Iterator | erase (ConstIterator pos) noexcept |
| | Erase element at iterator position.
|
| Iterator | erase (ConstIterator first, ConstIterator last) noexcept |
| | Erase range of elements.
|
|
void | clear () noexcept |
| | Clear all elements from the set.
|
| template<typename KeyType = TKey> |
| std::optional< TKey > | extract (const KeyType &key) |
| | Extract and remove a key from the set.
|
| void | merge (FastHashSet &other) |
| | Merge elements from another set into this set.
|
| void | merge (FastHashSet &&other) |
| | Merge elements from another set into this set (rvalue overload).
|
| size_t | size () const noexcept |
| | Get the number of elements in the set.
|
| size_t | capacity () const noexcept |
| | Get the current capacity of the hash table.
|
| bool | isEmpty () const noexcept |
| | Check if the set is empty.
|
| void | swap (FastHashSet &other) noexcept |
| | Swap contents with another set.
|
| Iterator | begin () noexcept |
| | Get iterator to beginning of occupied buckets.
|
| ConstIterator | begin () const noexcept |
| | Get const iterator to beginning of occupied buckets.
|
| Iterator | end () noexcept |
| | Get iterator to end (past last occupied bucket).
|
| ConstIterator | end () const noexcept |
| | Get const iterator to end (past last occupied bucket).
|
| ConstIterator | cbegin () const noexcept |
| | Get const iterator to beginning of occupied buckets (explicit const).
|
| ConstIterator | cend () const noexcept |
| | Get const iterator to end (explicit const).
|
| bool | operator== (const FastHashSet &other) const noexcept |
| | Compare two FastHashSets for equality.
|
template<typename TKey, hashing::Hash32or64 HashType = uint32_t, HashType Seed = ( sizeof( HashType ) == 4 ? hashing::constants::FNV_OFFSET_BASIS_32 : hashing::constants::FNV_OFFSET_BASIS_64 ), typename THasher = hashing::Hasher<HashType, Seed>, typename KeyEqual = std::equal_to<>>
class nfx::containers::FastHashSet< TKey, HashType, Seed, THasher, KeyEqual >
Hash set with Robin Hood hashing for bounded probe distances and predictable performance.
- Template Parameters
-
| TKey | Key type (supports heterogeneous lookup for compatible types like string_view) |
| HashType | Hash type - either uint32_t or uint64_t (default: uint32_t) |
| Seed | Hash seed value for initialization (default: FNV offset basis for HashType) |
| THasher | Hash functor type (default: hashing::Hasher<HashType, Seed>) |
| KeyEqual | Key equality comparator (default: std::equal_to<> for transparent comparison) |
Definition at line 71 of file FastHashSet.h.
template<typename TKey, hashing::Hash32or64 HashType = uint32_t, HashType Seed = ( sizeof( HashType ) == 4 ? hashing::constants::FNV_OFFSET_BASIS_32 : hashing::constants::FNV_OFFSET_BASIS_64 ), typename THasher = hashing::Hasher<HashType, Seed>, typename KeyEqual = std::equal_to<>>
template<typename... Args>
Construct and insert a key in-place.
- Template Parameters
-
| Args | Constructor argument types for TKey |
- Parameters
-
| args | Arguments forwarded to TKey constructor |
- Returns
- true if key was inserted, false if key already exists
Constructs key in-place using perfect forwarding, avoiding unnecessary copies
template<typename TKey, hashing::Hash32or64 HashType = uint32_t, HashType Seed = ( sizeof( HashType ) == 4 ? hashing::constants::FNV_OFFSET_BASIS_32 : hashing::constants::FNV_OFFSET_BASIS_64 ), typename THasher = hashing::Hasher<HashType, Seed>, typename KeyEqual = std::equal_to<>>
template<typename KeyType = TKey>
Extract and remove a key from the set.
- Template Parameters
-
| KeyType | Key type (supports heterogeneous lookup for compatible types) |
- Parameters
-
- Returns
- std::optional containing the extracted key if found, std::nullopt otherwise
Removes the key from the set and returns it. If the key is not found, returns std::nullopt. This operation invalidates iterators to the extracted element.
- Note
- This function is marked [[nodiscard]] - the return value should not be ignored