Sane C++ Libraries: SC::VectorMap< Key, Value, Container (original) (raw)

A map holding VectorMapItem key-value pairs in an unsorted Vector. More...

#include <[VectorMap.h](VectorMap%5F8h%5Fsource.html)>

Public Member Functions
auto size () const
Return the number of key-value pairs in the map.
auto isEmpty () const
Check if the map is empty.
Item * begin ()
const Item * begin () const
Item * end ()
const Item * end () const
template
bool remove (const ComparableToKey &key)
Remove an item with matching key from the Map.
bool insertIfNotExists (Item &&item)
Inserts an item if it doesn't exist already.
Value * insertOverwrite (Item &&item)
Insert an item, overwriting the potentially already existing one.
Key * insertValueUniqueKey (Value &&value)
Inserts a new value, automatically generating key with Key::generateUniqueKey (works for StrongID for example)
template
bool contains (const ComparableToKey &key) const
Check if the given key is contained in the map.
template
bool contains (const ComparableToKey &key, const Value *&outValue) const
Check if the given key is contained in the map.
template
bool contains (const ComparableToKey &key, Value *&outValue)
Check if the given key is contained in the map.
template
const Value * get (const ComparableToKey &key) const
Get the Value associated to the given key.
template
Value * get (const ComparableToKey &key)
Get the Value associated to the given key.
template
Value * getOrCreate (const ComparableToKey &key)
Get the value associated to the given key, or creates a new one if needed.
Public Attributes
Container items

template<typename Key, typename Value, typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>
struct SC::VectorMap< Key, Value, Container >

A map holding VectorMapItem key-value pairs in an unsorted Vector.

Template Parameters

Key Type of the key (must support == comparison)
Value Value type associated with Key
Container Container used for the Map

contains() [1/3]

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

bool SC::VectorMap< Key, Value, Container >::contains ( const ComparableToKey & key) const inlinenodiscard

Check if the given key is contained in the map.

contains() [2/3]

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

bool SC::VectorMap< Key, Value, Container >::contains ( const ComparableToKey & key, const Value *& outValue ) const inlinenodiscard

Check if the given key is contained in the map.

Parameters

key The key to search for inside current map
outValue A reference that will receive pointer to the found element (if found)

contains() [3/3]

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

bool SC::VectorMap< Key, Value, Container >::contains ( const ComparableToKey & key, Value *& outValue ) inlinenodiscard

Check if the given key is contained in the map.

Parameters

key The key to search for inside current map
outValue A reference that will receive pointer to the found element (if found)

get() [1/2]

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

Value * SC::VectorMap< Key, Value, Container >::get ( const ComparableToKey & key) inlinenodiscard

Get the Value associated to the given key.

Returns

A pointer to the value if it exists in the map, nullptr otherwise

get() [2/2]

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

const Value * SC::VectorMap< Key, Value, Container >::get ( const ComparableToKey & key) const inlinenodiscard

Get the Value associated to the given key.

Returns

A pointer to the value if it exists in the map, nullptr otherwise

getOrCreate()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

Value * SC::VectorMap< Key, Value, Container >::getOrCreate ( const ComparableToKey & key) inlinenodiscard

Get the value associated to the given key, or creates a new one if needed.

Returns

A pointer to the value or nullptr if the map is full

insertIfNotExists()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

bool SC::VectorMap< Key, Value, Container >::insertIfNotExists ( Item && item) inlinenodiscard

Inserts an item if it doesn't exist already.

Parameters

Returns

false if item already exists or if insertion fails (true otherwise)

insertOverwrite()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

Value * SC::VectorMap< Key, Value, Container >::insertOverwrite ( Item && item) inlinenodiscard

Insert an item, overwriting the potentially already existing one.

Parameters

Returns

A pointer to the Value if insertion succeeds, nullptr if insertion fails.

insertValueUniqueKey()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

Key * SC::VectorMap< Key, Value, Container >::insertValueUniqueKey ( Value && value) inlinenodiscard

Inserts a new value, automatically generating key with Key::generateUniqueKey (works for StrongID for example)

Parameters

value The new value to be inserted

Returns

A pointer to the new Key or nullptr if the map is full

isEmpty()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

auto SC::VectorMap< Key, Value, Container >::isEmpty ( ) const inlinenodiscard

Check if the map is empty.

remove()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

template

bool SC::VectorMap< Key, Value, Container >::remove ( const ComparableToKey & key) inlinenodiscard

Remove an item with matching key from the Map.

Parameters

key The key that must be removed

Returns

true if the item was found

size()

template<typename Key , typename Value , typename Container = SC::Vector<SC::VectorMapItem<Key, Value>>>

auto SC::VectorMap< Key, Value, Container >::size ( ) const inlinenodiscard

Return the number of key-value pairs in the map.


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