99 if (this->
free.Size() == 0)
103 SizeT oldCapacity = this->
free.Capacity();
106 n_assert2((
uint)(oldCapacity + growTo) < this->
maxId,
"Pool is full! Be careful with how much you allocate!\n");
109 this->
free.Reserve(oldCapacity + growTo);
111 for (i = this->
free.Capacity()-1; i >= oldCapacity; i--)
120 this->
free.EraseIndex(this->
free.Size() - 1);
139 this->
maxId = numIds;
140 this->
free.Reserve(numIds);
141 for (
int i = numIds - 1; i >= 0; i--)
153 return this->
free.Capacity() - this->
free.Size();
162 return this->
free.Size();
172 for (
IndexT i = size - 1; i >= 0; i--)
190 this->
free.EraseIndex(idx);
~IdPool()
destructor
Definition idpool.h:87
void Move(uint lhs, uint rhs)
frees up lhs and erases rhs
Definition idpool.h:187
Util::Array< uint > free
Definition idpool.h:56
IdPool()
constructor
Definition idpool.h:65
uint GetNumFree() const
get number of free elements
Definition idpool.h:160
const uint GetGrow() const
get grow
Definition idpool.h:197
uint maxId
Definition idpool.h:57
uint GetNumUsed() const
get number of active ids
Definition idpool.h:151
void ForEachFree(const std::function< void(uint, uint)> fun, SizeT num)
iterate free indices
Definition idpool.h:169
uint Alloc()
get new id
Definition idpool.h:96
uint grow
Definition idpool.h:58
void Reserve(uint numIds)
reserve ids
Definition idpool.h:137
void Dealloc(uint id)
free id
Definition idpool.h:128
Nebula's dynamic array class.
Definition array.h:60
#define n_assert2(exp, msg)
Definition debug.h:51
This simple Id pool implements a set of free and used consecutive integers.
Definition id.h:135
__forceinline TYPE min(TYPE a, TYPE b)
Definition scalar.h:399
Nebula's scalar datatype.
int SizeT
Definition types.h:49
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48