SolidUtils
Public Member Functions | Static Public Attributes | List of all members
sl::FixedMap< K, V > Class Template Reference

The FixedMap class provides a map 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), and store the data in a contiguous chunk of memory. More...

#include <FixedMap.hpp>

Public Member Functions

 FixedMap (size_t const size)
 Create a new empty fixed set. More...
 
bool has (K const key) const noexcept
 Check if an key exists in this set. More...
 
get (K const key) const noexcept
 Get the value associated with a given key. More...
 
void add (K const key, V const value) noexcept
 Add an key-value pair to this set. More...
 
void remove (K const key) noexcept
 Remove an key-value pair from this set. More...
 
size_t size () const noexcept
 Get the number of elements in the set. More...
 
size_t maxSize () const noexcept
 Get the maximum size of this map. More...
 
ConstArray< K > keys () const noexcept
 Get the keys in this map. More...
 
ConstArray< V > values () const noexcept
 Get the values in this map. More...
 

Static Public Attributes

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

Detailed Description

template<typename K, typename V>
class sl::FixedMap< K, V >

The FixedMap class provides a map 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), and store the data in a contiguous chunk of memory.

Template Parameters
KThe key type, must an integer.
VThe value type, must be trivial.

Constructor & Destructor Documentation

◆ FixedMap()

template<typename K , typename V >
sl::FixedMap< K, V >::FixedMap ( size_t const  size)
inline

Create a new empty fixed set.

Parameters
sizeThe size of the set.

Member Function Documentation

◆ add()

template<typename K , typename V >
void sl::FixedMap< K, V >::add ( K const  key,
V const  value 
)
inlinenoexcept

Add an key-value pair to this set.

Parameters
keyThe key.
valueThe value.

◆ get()

template<typename K , typename V >
V sl::FixedMap< K, V >::get ( K const  key) const
inlinenoexcept

Get the value associated with a given key.

Parameters
keyThe key.
Returns
The value.

◆ has()

template<typename K , typename V >
bool sl::FixedMap< K, V >::has ( K const  key) const
inlinenoexcept

Check if an key exists in this set.

Parameters
keyThe key.
Returns
True if the key is in the map.

◆ keys()

template<typename K , typename V >
ConstArray<K> sl::FixedMap< K, V >::keys ( ) const
inlinenoexcept

Get the keys in this map.

Returns
The keys.

◆ maxSize()

template<typename K , typename V >
size_t sl::FixedMap< K, V >::maxSize ( ) const
inlinenoexcept

Get the maximum size of this map.

Returns
The maximum size.

◆ remove()

template<typename K , typename V >
void sl::FixedMap< K, V >::remove ( K const  key)
inlinenoexcept

Remove an key-value pair from this set.

Parameters
keyThe key to remove.

◆ size()

template<typename K , typename V >
size_t sl::FixedMap< K, V >::size ( ) const
inlinenoexcept

Get the number of elements in the set.

Returns
The number of elements.

◆ values()

template<typename K , typename V >
ConstArray<V> sl::FixedMap< K, V >::values ( ) const
inlinenoexcept

Get the values in this map.

Returns
The values.

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