Nebula
|
#include <fixedpool.h>
Implements a fixed size pool, from which objects of a specific type can be allocated and freed for reuse.
Public Types | |
typedef TYPE * | Iterator |
define iterator | |
Public Member Functions | |
FixedPool () | |
default constructor | |
FixedPool (SizeT s, std::function< void(TYPE &val, IndexT idx)> setupFunc) | |
constructor with fixed size | |
~FixedPool () | |
destructor | |
void | operator= (const FixedArray< TYPE > &rhs) |
assignment operator | |
TYPE & | operator[] (const IndexT elem) |
access operator | |
TYPE & | Alloc () |
allocate an element in the pool | |
void | Free (const TYPE &elem) |
free element allocated from pool | |
void | Free (const Iterator iter) |
free element using iterator | |
SizeT | Size () const |
get number of elements | |
SizeT | NumFree () const |
get number of free elements | |
SizeT | NumUsed () const |
get number of used elements | |
void | Resize (SizeT newSize) |
reset pool and resize pool | |
bool | IsFull () const |
returns true if no more free values are available | |
bool | IsEmpty () const |
returns true if the pool is empty | |
void | Clear () |
clear all pool values | |
void | Reset () |
resets all used indices without clearing contents | |
void | SetSetupFunc (const std::function< void(TYPE &val, IndexT idx)> &func) |
set optional setup value | |
const Util::Array< TYPE > & | GetAllocated () |
get allocated values as array | |
Private Attributes | |
std::function< void(TYPE &val, IndexT idx)> | setupFunc |
SizeT | size |
Util::Array< TYPE > | freeValues |
Util::Array< TYPE > | usedValues |
TYPE* Util::FixedPool< TYPE >::Iterator |
define iterator
Util::FixedPool< TYPE >::FixedPool | ( | ) |
default constructor
Util::FixedPool< TYPE >::FixedPool | ( | SizeT | s, |
std::function< void(TYPE &val, IndexT idx)> | setupFunc ) |
constructor with fixed size
Util::FixedPool< TYPE >::~FixedPool | ( | ) |
destructor
TYPE & Util::FixedPool< TYPE >::Alloc | ( | ) |
allocate an element in the pool
void Util::FixedPool< TYPE >::Clear | ( | ) |
clear all pool values
void Util::FixedPool< TYPE >::Free | ( | const Iterator | iter | ) |
free element using iterator
void Util::FixedPool< TYPE >::Free | ( | const TYPE & | elem | ) |
free element allocated from pool
const Util::Array< TYPE > & Util::FixedPool< TYPE >::GetAllocated | ( | ) |
get allocated values as array
bool Util::FixedPool< TYPE >::IsEmpty | ( | ) | const |
returns true if the pool is empty
bool Util::FixedPool< TYPE >::IsFull | ( | ) | const |
returns true if no more free values are available
SizeT Util::FixedPool< TYPE >::NumFree | ( | ) | const |
get number of free elements
SizeT Util::FixedPool< TYPE >::NumUsed | ( | ) | const |
get number of used elements
void Util::FixedPool< TYPE >::operator= | ( | const FixedArray< TYPE > & | rhs | ) |
assignment operator
TYPE & Util::FixedPool< TYPE >::operator[] | ( | const IndexT | elem | ) |
access operator
void Util::FixedPool< TYPE >::Reset | ( | ) |
resets all used indices without clearing contents
void Util::FixedPool< TYPE >::Resize | ( | SizeT | newSize | ) |
reset pool and resize pool
void Util::FixedPool< TYPE >::SetSetupFunc | ( | const std::function< void(TYPE &val, IndexT idx)> & | func | ) |
set optional setup value
SizeT Util::FixedPool< TYPE >::Size | ( | ) | const |
get number of elements
|
private |
|
private |
|
private |
|
private |