Sane C++ Libraries
C++ Platform Abstraction Libraries
SC::ArenaMap< T > Struct Template Reference

A sparse vector keeping objects at a stable memory location. More...

#include <ArenaMap.h>

Classes

struct  ArenaMapIterator
 

Public Types

using Key = ArenaMapKey< T >
 
using ConstIterator = ArenaMapIterator< const ArenaMap >
 
using Iterator = ArenaMapIterator< ArenaMap >
 

Public Member Functions

 ArenaMap (const ArenaMap &other)
 
 ArenaMap (ArenaMap &&other)
 
ArenaMapoperator= (const ArenaMap &other)
 
ArenaMapoperator= (ArenaMap &&other)
 
uint32_t getNumAllocated () const
 Get the maximum number of objects that can be stored in this map. More...
 
ConstIterator cbegin () const
 
ConstIterator cend () const
 
ConstIterator begin () const
 
ConstIterator end () const
 
Iterator begin ()
 
Iterator end ()
 
void clear ()
 
size_t size () const
 Get the number of used slots in the arena. More...
 
size_t capacity () const
 Get the total number slots in the arena. More...
 
bool isFull () const
 Returns true if size() == capacity(), that means the arena is full. More...
 
bool resize (size_t newSize)
 Changes the size of the arena. More...
 
template<typename Value >
Key insert (const Value &object)
 
Key allocate ()
 
template<typename Value >
Key insert (Value &&object)
 
bool containsKey (Key key) const
 
template<typename ComparableToValue >
bool containsValue (const ComparableToValue &value, Key *optionalKey=nullptr) const
 
bool remove (Key key)
 
T * get (Key key)
 
const T * get (Key key) const
 

Detailed Description

template<typename T>
struct SC::ArenaMap< T >

A sparse vector keeping objects at a stable memory location.

Template Parameters
TType of items kept in this Arena

SC::ArenaMap is a container used to keep objects memory location stable.
Internally it hold sparse objects inside of a SC::Vector and for this reason it can only be SC::ArenaMap::resize-d when it's empty.
Objects can be inserted up to the SC::ArenaMap::size and insertion returns handle keys allowing to retrieve the inserted object in constant time.

Member Function Documentation

◆ capacity()

template<typename T >
size_t SC::ArenaMap< T >::capacity ( ) const
inline

Get the total number slots in the arena.

◆ getNumAllocated()

template<typename T >
uint32_t SC::ArenaMap< T >::getNumAllocated ( ) const
inline

Get the maximum number of objects that can be stored in this map.

◆ isFull()

template<typename T >
bool SC::ArenaMap< T >::isFull ( ) const
inline

Returns true if size() == capacity(), that means the arena is full.

◆ resize()

template<typename T >
bool SC::ArenaMap< T >::resize ( size_t  newSize)
inline

Changes the size of the arena.

Note
Can only be called on empty arena (SC::ArenaMap::size == 0)
Parameters
newSizeThe new wanted number of elements to be stored in the arena
Returns
true if resize succeeded

◆ size()

template<typename T >
size_t SC::ArenaMap< T >::size ( ) const
inline

Get the number of used slots in the arena.


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