|
|
| OrderedHashSet () |
| | Default constructor with initial capacity of 32 elements.
|
| | OrderedHashSet (std::initializer_list< TKey > init) |
| | Construct set from initializer_list.
|
| template<typename InputIt> |
| | OrderedHashSet (InputIt first, InputIt last) |
| | Construct set from iterator range.
|
| | OrderedHashSet (size_t initialCapacity) |
| | Constructor with specified initial capacity.
|
| | OrderedHashSet (OrderedHashSet &&other) noexcept |
| | Move constructor.
|
| OrderedHashSet & | operator= (OrderedHashSet &&other) noexcept |
| | Move assignment operator.
|
| | OrderedHashSet (const OrderedHashSet &other) |
| | Copy constructor.
|
| OrderedHashSet & | operator= (const OrderedHashSet &other) |
| | Copy assignment operator.
|
|
| ~OrderedHashSet () |
| | 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 (OrderedHashSet &other) |
| | Merge elements from another set into this set.
|
| void | merge (OrderedHashSet &&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 (OrderedHashSet &other) noexcept |
| | Swap contents with another set.
|
| Iterator | begin () noexcept |
| | Get iterator to first element in insertion order.
|
| ConstIterator | begin () const noexcept |
| | Get const iterator to first element in insertion order.
|
| Iterator | end () noexcept |
| | Get iterator to end (past last element in insertion order).
|
| ConstIterator | end () const noexcept |
| | Get const iterator to end (past last element in insertion order).
|
| ConstIterator | cbegin () const noexcept |
| | Get const iterator to first element in insertion order (explicit const).
|
| ConstIterator | cend () const noexcept |
| | Get const iterator to end (explicit const).
|
| bool | operator== (const OrderedHashSet &other) const noexcept |
| | Compare two OrderedHashSets 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::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >
Hash set with Robin Hood hashing and insertion-order preservation.
- Template Parameters
-
| TKey | Key type (supports heterogeneous lookup for compatible types) |
| HashType | Hash type - 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) |
Combines O(1) hash table lookups with stable insertion-order iteration. Uses Robin Hood hashing for the hash table and an intrusive doubly-linked list to maintain insertion order. Iteration follows insertion order, not bucket order.
Definition at line 76 of file OrderedHashSet.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 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. The insertion order of remaining elements is preserved.
- Note
- This function is marked [[nodiscard]] - the return value should not be ignored
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<>>
Merge elements from another set into this set.
- Parameters
-
| other | Source set to merge from (modified - unique elements are moved out) |
Attempts to move each element from 'other' into this set in insertion order. Elements that already exist in this set (duplicates) remain in 'other'. After merge, 'other' contains only elements that were duplicates. Insertion order is preserved for both sets.