Rebel Fork Framework
|
Utility to assign unique non-zero IDs to objects. Thread-safe. More...
#include <Urho3D/Container/IndexAllocator.h>
Public Types | |
using | MutexType = T |
Public Member Functions | |
unsigned | GetNextFreeIndex () const |
Return upper bound of allocated indices. | |
unsigned | GetSize () const |
Return number of currently allocated indices. | |
unsigned | Allocate () |
Allocate index. | |
void | Release (unsigned index) |
Release index. Index should be previously returned from Allocate and not released yet. | |
void | Shrink () |
Shrink collection to minimum possible size preserving currently allocated indices. | |
void | Clear () |
Reset to default state. | |
Private Attributes | |
MutexType | mutex_ |
Mutex that protects list and index. | |
std::atomic_uint32_t | nextIndex_ { 1 } |
Next unused index. | |
ea::vector< unsigned > | unusedIndices_ |
Unused indices. | |
Utility to assign unique non-zero IDs to objects. Thread-safe.