Nebula
Loading...
Searching...
No Matches
Util::FixedPool< TYPE > Class Template Reference

#include <fixedpool.h>

Detailed Description

template<class TYPE>
class Util::FixedPool< TYPE >

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

Member Typedef Documentation

◆ Iterator

template<class TYPE>
typedef TYPE* Util::FixedPool< TYPE >::Iterator

define iterator

Constructor & Destructor Documentation

◆ FixedPool() [1/2]

template<class TYPE>
Util::FixedPool< TYPE >::FixedPool ( )
inline

default constructor

◆ FixedPool() [2/2]

template<class TYPE>
Util::FixedPool< TYPE >::FixedPool ( SizeT s,
std::function< void(TYPE &val, IndexT idx)> setupFunc )
inline

constructor with fixed size

◆ ~FixedPool()

template<class TYPE>
Util::FixedPool< TYPE >::~FixedPool ( )
inline

destructor

Member Function Documentation

◆ Alloc()

template<class TYPE>
TYPE & Util::FixedPool< TYPE >::Alloc ( )
inline

allocate an element in the pool

◆ Clear()

template<class TYPE>
void Util::FixedPool< TYPE >::Clear ( )
inline

clear all pool values

◆ Free() [1/2]

template<class TYPE>
void Util::FixedPool< TYPE >::Free ( const Iterator iter)
inline

free element using iterator

◆ Free() [2/2]

template<class TYPE>
void Util::FixedPool< TYPE >::Free ( const TYPE & elem)
inline

free element allocated from pool

◆ GetAllocated()

template<class TYPE>
const Util::Array< TYPE > & Util::FixedPool< TYPE >::GetAllocated ( )
inline

get allocated values as array

◆ IsEmpty()

template<class TYPE>
bool Util::FixedPool< TYPE >::IsEmpty ( ) const
inline

returns true if the pool is empty

◆ IsFull()

template<class TYPE>
bool Util::FixedPool< TYPE >::IsFull ( ) const
inline

returns true if no more free values are available

◆ NumFree()

template<class TYPE>
SizeT Util::FixedPool< TYPE >::NumFree ( ) const
inline

get number of free elements

◆ NumUsed()

template<class TYPE>
SizeT Util::FixedPool< TYPE >::NumUsed ( ) const
inline

get number of used elements

◆ operator=()

template<class TYPE>
void Util::FixedPool< TYPE >::operator= ( const FixedArray< TYPE > & rhs)
inline

assignment operator

◆ operator[]()

template<class TYPE>
TYPE & Util::FixedPool< TYPE >::operator[] ( const IndexT elem)

access operator

◆ Reset()

template<class TYPE>
void Util::FixedPool< TYPE >::Reset ( )
inline

resets all used indices without clearing contents

◆ Resize()

template<class TYPE>
void Util::FixedPool< TYPE >::Resize ( SizeT newSize)
inline

reset pool and resize pool

◆ SetSetupFunc()

template<class TYPE>
void Util::FixedPool< TYPE >::SetSetupFunc ( const std::function< void(TYPE &val, IndexT idx)> & func)
inline

set optional setup value

◆ Size()

template<class TYPE>
SizeT Util::FixedPool< TYPE >::Size ( ) const
inline

get number of elements

Member Data Documentation

◆ freeValues

template<class TYPE>
Util::Array<TYPE> Util::FixedPool< TYPE >::freeValues
private

◆ setupFunc

template<class TYPE>
std::function<void(TYPE& val, IndexT idx)> Util::FixedPool< TYPE >::setupFunc
private

◆ size

template<class TYPE>
SizeT Util::FixedPool< TYPE >::size
private

◆ usedValues

template<class TYPE>
Util::Array<TYPE> Util::FixedPool< TYPE >::usedValues
private

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