template<class Titem, typename Tindex, size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >
Base class for all pools.
- Template Parameters
-
Titem | Type of the class/struct that is going to be pooled |
Tindex | Type of the index for this pool |
Tgrowth_step | Size of growths; if the pool is full increase the size by this amount |
Tmax_size | Maximum size of the pool |
Tpool_type | Type of this pool |
Tcache | Whether to perform 'alloc' caching, i.e. don't actually free/malloc just reuse the memory |
Tzero | Whether to zero the memory |
- Warning
- when Tcache is enabled all instances of this pool's item must be of the same size.
Definition at line 80 of file pool_type.hpp.
template<class Titem , typename Tindex , size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::CanAllocate |
( |
size_t |
n = 1 | ) |
|
|
inline |
Tests whether we can allocate 'n' items.
- Parameters
-
n | number of items we want to allocate |
- Returns
- true if 'n' items can be allocated
Definition at line 133 of file pool_type.hpp.
template<class Titem , typename Tindex , size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
Titem* Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::Get |
( |
size_t |
index | ) |
|
|
inline |
Returns Titem with given index.
- Parameters
-
- Returns
- pointer to Titem
- Precondition
- index < this->first_unused
Definition at line 112 of file pool_type.hpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::first_unused.
Referenced by Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::IsValidID().
template<class Titem , typename Tindex , size_t Tgrowth_step, size_t Tmax_size, PoolType Tpool_type = PT_NORMAL, bool Tcache = false, bool Tzero = true>
bool Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::IsValidID |
( |
size_t |
index | ) |
|
|
inline |