28#if GENERATION_BITS <= 8
30#elif GENERATION_BITS <= 16
35#if ID_BITS + GENERATION_BITS > 32
36#error bits in game id generation exceeds 32
91 id = (generation <<
ID_BITS) | index;
Provides a system for creating array friendly id numbers with reuse and generations.
Definition idgenerationpool.h:43
void Deallocate(Id32 id)
remove an id
Definition idgenerationpool.cc:54
bool IsValid(Id32 id) const
check if valid
Definition idgenerationpool.cc:66
Util::Queue< Id32 > freeIds
stores freed indices
Definition idgenerationpool.h:62
IdGenerationPool()
constructor
Definition idgenerationpool.cc:14
bool Allocate(Id32 &id)
allocate a new id, returns true if a new id was created, and false if an id was reused but with new g...
Definition idgenerationpool.cc:33
SizeT freeIdsSize
Definition idgenerationpool.h:63
Util::Array< generation_t > generations
array containing generation value for every index
Definition idgenerationpool.h:59
~IdGenerationPool()
destructor
Definition idgenerationpool.cc:24
Nebula's dynamic array class.
Definition array.h:60
Nebula's queue class (a FIFO container).
Definition queue.h:28
#define n_assert2(exp, msg)
Definition debug.h:51
const uint32_t GENERATION_MASK
Definition idgenerationpool.h:26
uint8_t generation_t
Definition idgenerationpool.h:29
const uint32_t ID_BITS
Definition idgenerationpool.h:23
const uint32_t GENERATION_BITS
Definition idgenerationpool.h:24
const uint32_t ID_MASK
Definition idgenerationpool.h:25
This simple Id pool implements a set of free and used consecutive integers.
Definition id.h:135
uint32_t Id24
Definition id.h:139
static constexpr Id24 Index(const Id32 id)
Definition idgenerationpool.h:70
static Id32 CreateId(const Id24 index, generation_t generation)
Definition idgenerationpool.h:88
uint32_t Id32
Definition id.h:138
static constexpr generation_t Generation(const Id32 id)
Definition idgenerationpool.h:79
int SizeT
Definition types.h:49