Rebel Fork Framework
Urho3D::IndexAllocator< T > Class Template Reference

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.
 

Detailed Description

template<class T = DummyMutex>
class Urho3D::IndexAllocator< T >

Utility to assign unique non-zero IDs to objects. Thread-safe.


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