SolidUtils
Public Member Functions | Static Public Attributes | List of all members
sl::FixedSet< T > Class Template Reference

The FixedSet class provides a set implementation which allows for insertion, querying, and deletion in constant time. While std::unordered_set may give constant time complexity of these operations through a hash table, this does so through fixed size dense vector (no hashing). More...

#include <FixedSet.hpp>

Public Member Functions

 FixedSet (size_t const size)
 Create a new empty fixed set. More...
 
bool has (T const element) const noexcept
 Check if an element exists in this set. More...
 
void add (T const element) noexcept
 Add an element to this set. More...
 
void remove (T const element) noexcept
 Remove an element from this set. More...
 
T * data () noexcept
 Get the underlying array. More...
 
T const * data () const noexcept
 Get the underlying array. More...
 
size_t size () const noexcept
 Get the number of elements in the set. More...
 
T const * begin () const noexcept
 Get the beginning iterator. More...
 
T const * end () const noexcept
 Get the end iterator. More...
 
T * begin () noexcept
 Get the beginning iterator (mutable). More...
 
T * end () noexcept
 Get the end iterator (mutable). More...
 

Static Public Attributes

static constexpr T const NULL_INDEX = static_cast<T>(-1)
 

Detailed Description

template<typename T>
class sl::FixedSet< T >

The FixedSet class provides a set implementation which allows for insertion, querying, and deletion in constant time. While std::unordered_set may give constant time complexity of these operations through a hash table, this does so through fixed size dense vector (no hashing).

Template Parameters
TThe type of element to store.

Constructor & Destructor Documentation

◆ FixedSet()

template<typename T >
sl::FixedSet< T >::FixedSet ( size_t const  size)
inline

Create a new empty fixed set.

Parameters
sizeThe size of the set.

Member Function Documentation

◆ add()

template<typename T >
void sl::FixedSet< T >::add ( T const  element)
inlinenoexcept

Add an element to this set.

Parameters
elementThe element to add.

◆ begin() [1/2]

template<typename T >
T const* sl::FixedSet< T >::begin ( ) const
inlinenoexcept

Get the beginning iterator.

Returns
The iterator/pointer.

◆ begin() [2/2]

template<typename T >
T* sl::FixedSet< T >::begin ( )
inlinenoexcept

Get the beginning iterator (mutable).

Returns
The iterator/pointer.

◆ data() [1/2]

template<typename T >
T* sl::FixedSet< T >::data ( )
inlinenoexcept

Get the underlying array.

Returns
The data.

◆ data() [2/2]

template<typename T >
T const* sl::FixedSet< T >::data ( ) const
inlinenoexcept

Get the underlying array.

Returns
The data.

◆ end() [1/2]

template<typename T >
T const* sl::FixedSet< T >::end ( ) const
inlinenoexcept

Get the end iterator.

Returns
The iterator/pointer.

◆ end() [2/2]

template<typename T >
T* sl::FixedSet< T >::end ( )
inlinenoexcept

Get the end iterator (mutable).

Returns
The iterator/pointer.

◆ has()

template<typename T >
bool sl::FixedSet< T >::has ( T const  element) const
inlinenoexcept

Check if an element exists in this set.

Parameters
elementThe element.
Returns
True if the element is in the set.

◆ remove()

template<typename T >
void sl::FixedSet< T >::remove ( T const  element)
inlinenoexcept

Remove an element from this set.

Parameters
elementThe element to remove.

◆ size()

template<typename T >
size_t sl::FixedSet< T >::size ( ) const
inlinenoexcept

Get the number of elements in the set.

Returns
The number of elements.

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