nfx-containers 0.6.0
Modern C++20 header-only library providing high-performance hash containers with Robin Hood and perfect hashing
Loading...
Searching...
No Matches
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > Class Template Referencefinal

Hash set with Robin Hood hashing and insertion-order preservation. More...

#include <nfx/containers/OrderedHashSet.h>

Classes

class  Iterator
 Iterator for OrderedHashSet that follows insertion order. More...
class  ConstIterator
 Const iterator for OrderedHashSet that follows insertion order. More...

Public Types

using key_type = TKey
 Type alias for key type.
using value_type = TKey
 Type alias for value type (same as key for sets).
using hasher = THasher
 Type alias for hasher type.
using key_equal = KeyEqual
 Type alias for key equality comparator.
using hash_type = HashType
 Type alias for hash type (uint32_t or uint64_t).
using size_type = size_t
 Type alias for size type.
using difference_type = std::ptrdiff_t
 Type alias for difference type.
using iterator = Iterator
 Type alias for iterator.
using const_iterator = ConstIterator
 Type alias for const iterator.

Public Member Functions

 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.
OrderedHashSetoperator= (OrderedHashSet &&other) noexcept
 Move assignment operator.
 OrderedHashSet (const OrderedHashSet &other)
 Copy constructor.
OrderedHashSetoperator= (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.

Detailed Description

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
TKeyKey type (supports heterogeneous lookup for compatible types)
HashTypeHash type - uint32_t or uint64_t (default: uint32_t)
SeedHash seed value for initialization (default: FNV offset basis for HashType)
THasherHash functor type (default: hashing::Hasher<HashType, Seed>)
KeyEqualKey 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.

Member Typedef Documentation

◆ const_iterator

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::const_iterator = ConstIterator

Type alias for const iterator.

Definition at line 128 of file OrderedHashSet.h.

◆ difference_type

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::difference_type = std::ptrdiff_t

Type alias for difference type.

Definition at line 122 of file OrderedHashSet.h.

◆ hash_type

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::hash_type = HashType

Type alias for hash type (uint32_t or uint64_t).

Definition at line 116 of file OrderedHashSet.h.

◆ hasher

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::hasher = THasher

Type alias for hasher type.

Definition at line 110 of file OrderedHashSet.h.

◆ iterator

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::iterator = Iterator

Type alias for iterator.

Definition at line 125 of file OrderedHashSet.h.

◆ key_equal

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::key_equal = KeyEqual

Type alias for key equality comparator.

Definition at line 113 of file OrderedHashSet.h.

◆ key_type

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::key_type = TKey

Type alias for key type.

Definition at line 104 of file OrderedHashSet.h.

◆ size_type

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::size_type = size_t

Type alias for size type.

Definition at line 119 of file OrderedHashSet.h.

◆ value_type

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<>>
using nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::value_type = TKey

Type alias for value type (same as key for sets).

Definition at line 107 of file OrderedHashSet.h.

Constructor & Destructor Documentation

◆ OrderedHashSet() [1/5]

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<>>
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::OrderedHashSet ( std::initializer_list< TKey > init)
inline

Construct set from initializer_list.

Parameters
initInitializer list of keys

◆ OrderedHashSet() [2/5]

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 InputIt>
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::OrderedHashSet ( InputIt first,
InputIt last )
inline

Construct set from iterator range.

Template Parameters
InputItInput iterator type (must dereference to TKey)
Parameters
firstBeginning of range to copy from
lastEnd of range (exclusive)

◆ OrderedHashSet() [3/5]

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<>>
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::OrderedHashSet ( size_t initialCapacity)
inlineexplicit

Constructor with specified initial capacity.

Parameters
initialCapacityMinimum initial capacity (rounded up to power of 2)

◆ OrderedHashSet() [4/5]

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<>>
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::OrderedHashSet ( OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > && other)
noexcept

Move constructor.

Parameters
otherSet to move from

◆ OrderedHashSet() [5/5]

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<>>
nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::OrderedHashSet ( const OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > & other)

Copy constructor.

Parameters
otherSet to copy from (preserves insertion order)

Member Function Documentation

◆ at()

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>
const TKey & nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::at ( const KeyType & key) const
inline

Checked element access with bounds checking.

Template Parameters
KeyTypeKey type (supports heterogeneous lookup)
Parameters
keyThe key to access
Returns
Const reference to the key
Exceptions
std::out_of_rangeif key is not found
Note
For sets, at() returns the key itself (useful for retrieving stored key)

◆ begin() [1/2]

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<>>
ConstIterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::begin ( ) const
nodiscardnoexcept

Get const iterator to first element in insertion order.

Returns
Const iterator pointing to first inserted key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ begin() [2/2]

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<>>
Iterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::begin ( )
nodiscardnoexcept

Get iterator to first element in insertion order.

Returns
Iterator pointing to first inserted key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ capacity()

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<>>
size_t nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::capacity ( ) const
inlinenodiscardnoexcept

Get the current capacity of the hash table.

Returns
Maximum elements before resize (always power of 2)

◆ cbegin()

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<>>
ConstIterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::cbegin ( ) const
nodiscardnoexcept

Get const iterator to first element in insertion order (explicit const).

Returns
Const iterator pointing to first inserted key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ cend()

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<>>
ConstIterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::cend ( ) const
nodiscardnoexcept

Get const iterator to end (explicit const).

Returns
Const iterator pointing past the last key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ contains()

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>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::contains ( const KeyType & key) const
inlinenodiscardnoexcept

Check if a key exists in the set.

Template Parameters
KeyTypeKey type (supports heterogeneous lookup for compatible types)
Parameters
keyThe key to search for
Returns
true if key exists, false otherwise
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ emplace()

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>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::emplace ( Args &&... args)
inline

Construct and insert a key in-place.

Template Parameters
ArgsConstructor argument types for TKey
Parameters
argsArguments forwarded to TKey constructor
Returns
true if key was inserted, false if key already exists
Note
New keys are appended to end of insertion order

◆ end() [1/2]

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<>>
ConstIterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::end ( ) const
nodiscardnoexcept

Get const iterator to end (past last element in insertion order).

Returns
Const iterator pointing past the last key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ end() [2/2]

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<>>
Iterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::end ( )
nodiscardnoexcept

Get iterator to end (past last element in insertion order).

Returns
Iterator pointing past the last key
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ erase() [1/3]

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>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::erase ( const KeyType & key)
inlinenoexcept

Remove a key from the set.

Template Parameters
KeyTypeKey type (supports heterogeneous lookup for compatible types)
Parameters
keyThe key to remove
Returns
true if the key was found and removed, false otherwise
Note
Preserves insertion order of remaining elements

◆ erase() [2/3]

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<>>
Iterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::erase ( ConstIterator first,
ConstIterator last )
inlinenoexcept

Erase range of elements.

Parameters
firstBeginning of range to erase (in insertion order)
lastEnd of range to erase (exclusive)
Returns
Iterator to the element following the last erased element

◆ erase() [3/3]

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<>>
Iterator nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::erase ( ConstIterator pos)
inlinenoexcept

Erase element at iterator position.

Parameters
posIterator to element to erase
Returns
Iterator to the element following the erased element in insertion order
Note
Iterator becomes invalid after erase

◆ extract()

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>
std::optional< TKey > nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::extract ( const KeyType & key)
inlinenodiscard

Extract and remove a key from the set.

Template Parameters
KeyTypeKey type (supports heterogeneous lookup for compatible types)
Parameters
keyThe key to extract
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

◆ find()

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>
const TKey * nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::find ( const KeyType & key) const
inlinenodiscardnoexcept

Fast lookup with heterogeneous key types (C++ idiom: pointer return).

Template Parameters
KeyTypeKey type (supports heterogeneous lookup for compatible types)
Parameters
keyThe key to search for
Returns
Pointer to the key if found, nullptr otherwise

◆ insert() [1/2]

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<>>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::insert ( const TKey & key)
inline

Insert a key into the set (copy semantics).

Parameters
keyThe key to insert
Returns
true if key was inserted, false if key already exists
Note
New keys are appended to end of insertion order

◆ insert() [2/2]

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<>>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::insert ( TKey && key)
inline

Insert a key into the set (move semantics).

Parameters
keyThe key to insert (moved)
Returns
true if key was inserted, false if key already exists
Note
New keys are appended to end of insertion order

◆ isEmpty()

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<>>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::isEmpty ( ) const
inlinenodiscardnoexcept

Check if the set is empty.

Returns
true if size() == 0, false otherwise

◆ merge() [1/2]

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<>>
void nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::merge ( OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > && other)
inline

Merge elements from another set into this set (rvalue overload).

Parameters
otherSource set to merge from (modified - unique elements are moved out)

◆ merge() [2/2]

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<>>
void nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::merge ( OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > & other)
inline

Merge elements from another set into this set.

Parameters
otherSource 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.

◆ operator=() [1/2]

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<>>
OrderedHashSet & nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::operator= ( const OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > & other)

Copy assignment operator.

Parameters
otherSet to copy from (preserves insertion order)
Returns
Reference to this set

◆ operator=() [2/2]

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<>>
OrderedHashSet & nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::operator= ( OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > && other)
noexcept

Move assignment operator.

Parameters
otherSet to move from
Returns
Reference to this set

◆ operator==()

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<>>
bool nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::operator== ( const OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > & other) const
nodiscardnoexcept

Compare two OrderedHashSets for equality.

Parameters
otherThe other OrderedHashSet to compare with
Returns
true if both sets contain the same keys (order-independent comparison)
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ reserve()

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<>>
void nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::reserve ( size_t minCapacity)
inline

Reserve capacity for at least the specified number of elements.

Parameters
minCapacityMinimum capacity to reserve
Note
Preserves insertion order during rehashing

◆ size()

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<>>
size_t nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::size ( ) const
inlinenodiscardnoexcept

Get the number of elements in the set.

Returns
Current number of keys stored

◆ swap()

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<>>
void nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::swap ( OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual > & other)
inlinenoexcept

Swap contents with another set.

Parameters
otherSet to swap with
Note
noexcept operation - just swaps internal pointers/values

◆ tryEmplace()

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>
std::pair< Iterator, bool > nfx::containers::OrderedHashSet< TKey, HashType, Seed, THasher, KeyEqual >::tryEmplace ( Args &&... args)
inline

Try to emplace a key if it doesn't exist.

Template Parameters
ArgsVariadic template for key constructor arguments
Parameters
argsArguments forwarded to TKey constructor (only used if key doesn't exist)
Returns
Pair of iterator to element and bool (true if inserted, false if key existed)
Note
More efficient than emplace() - doesn't construct key if it already exists
New keys are appended to end of insertion order

The documentation for this class was generated from the following file: