RedCore
Loading...
Searching...
No Matches
red::FixedObjectPool< T, N > Class Template Reference

A fixed-capacity, allocation-free container holding a pool of objects which get reused on acquire/release without destruction. Useful for handling recyclable objects which should only be initialized once but can be marked inactive and reused without re-creation. More...

#include <ObjectPool.h>

Public Member Functions

 FixedObjectPool ()
T * acquire ()
void release (T *obj)
u32 size () const
u32 capacity () const
bool isUsed (u32 i) const
bool contains (const T *obj) const
template<typename F>
void forEach (F fn, bool ignoreActivity=false)
template<typename F>
void forEach (F fn, bool ignoreActivity=false) const

Detailed Description

template<PoolObject T, u32 N>
class red::FixedObjectPool< T, N >

A fixed-capacity, allocation-free container holding a pool of objects which get reused on acquire/release without destruction. Useful for handling recyclable objects which should only be initialized once but can be marked inactive and reused without re-creation.

Template Parameters
TThe type of object to hold.
NMaximum capacity of the pool.

Insertion: O(1), Removal: O(1).

Constructor & Destructor Documentation

◆ FixedObjectPool()

template<PoolObject T, u32 N>
red::FixedObjectPool< T, N >::FixedObjectPool ( )
inline

Member Function Documentation

◆ acquire()

template<PoolObject T, u32 N>
T * red::FixedObjectPool< T, N >::acquire ( )
inline

◆ release()

template<PoolObject T, u32 N>
void red::FixedObjectPool< T, N >::release ( T * obj)
inline

◆ size()

template<PoolObject T, u32 N>
u32 red::FixedObjectPool< T, N >::size ( ) const
inline

◆ capacity()

template<PoolObject T, u32 N>
u32 red::FixedObjectPool< T, N >::capacity ( ) const
inline

◆ isUsed()

template<PoolObject T, u32 N>
bool red::FixedObjectPool< T, N >::isUsed ( u32 i) const
inline

◆ contains()

template<PoolObject T, u32 N>
bool red::FixedObjectPool< T, N >::contains ( const T * obj) const
inline

◆ forEach() [1/2]

template<PoolObject T, u32 N>
template<typename F>
void red::FixedObjectPool< T, N >::forEach ( F fn,
bool ignoreActivity = false )
inline

◆ forEach() [2/2]

template<PoolObject T, u32 N>
template<typename F>
void red::FixedObjectPool< T, N >::forEach ( F fn,
bool ignoreActivity = false ) const
inline