17 template <
typename T>
class IterablePool;
23 class IterablePool_Iterator
28 KY_INLINE IterablePool_Iterator();
29 KY_INLINE IterablePool_Iterator(const IterablePool<T>* iterablePool) { Init(iterablePool); }
30 KY_INLINE
void Init(
const IterablePool<T>* iterablePool);
31 KY_INLINE
bool Next();
32 KY_INLINE T& Get()
const {
return *m_ptr; }
35 const IterablePool<T>* m_iterablePool;
56 typedef PoolHandle<T> Handle;
58 typedef IterablePool_Iterator<T> Iterator;
64 OnNew(IterablePool* pool) : m_pool(pool), m_oldChunkCount(pool->GetChunkCount()) {}
65 Key Do(Key compactKey);
66 Handle Do(Handle handle);
73 explicit IterablePool(MemoryHeap* heap,
KyInt32 memStat, PoolChunkSize::Mode chunkSizeMode = PoolChunkSize::ByteSize,
KyUInt32 byteOrSlotCount = 256) :
74 m_basePool(heap, memStat, chunkSizeMode, byteOrSlotCount) {}
76 void Init(PoolChunkSize::Mode chunkSizeMode,
KyUInt32 byteOrSlotCount) { m_basePool.Init(chunkSizeMode, byteOrSlotCount); }
78 ~IterablePool() { Clear(); }
80 KY_INLINE
KyUInt32 GetCount()
const {
return m_basePool.GetCount(); }
85 KY_INLINE Key New_CompactKey() { OnNew onNew(
this);
return onNew.Do(m_basePool.New_CompactKey()); }
86 KY_INLINE Key New_CompactKey(
const T& data) { OnNew onNew(
this);
return onNew.Do(m_basePool.New_CompactKey(data)); }
88 KY_INLINE
void New_CompactKeyAndPtr(Key& key, T*& ptr) { OnNew onNew(
this); m_basePool.New_CompactKeyAndPtr(key, ptr); onNew.Do(key); }
90 KY_INLINE
const T& Get(Key key)
const {
return m_basePool.Get(key); }
91 KY_INLINE T& Get(Key key) {
return m_basePool.Get(key); }
93 KY_INLINE
void Delete(Key key) { m_basePool.Delete(key); m_bitField.UnsetBit(GetGlobalIdx(key)); }
96 KY_INLINE Handle New_Handle() { OnNew onNew(
this);
return onNew.Do(m_basePool.New_Handle()); }
97 KY_INLINE Handle New_Handle(
const T& data) { OnNew onNew(
this);
return onNew.Do(m_basePool.New_Handle(data)); }
98 KY_INLINE
void Delete(
const Handle& handle) { m_basePool.Delete(handle); m_bitField.UnsetBit(GetGlobalIdx(handle)); }
101 KY_INLINE T* New_Ptr() { OnNew onNew(
this);
return onNew.Do(m_basePool.New_Ptr()); }
102 KY_INLINE T* New_Ptr(
const T& data) { OnNew onNew(
this);
return onNew.Do(m_basePool.New_Ptr()); }
103 KY_INLINE
void Delete(T* ptr) { m_basePool.Delete(ptr); m_bitField.UnsetBit(GetGlobalIdx(ptr)); }
106 KY_INLINE Key Handle2CompactKey(
const Handle& h)
const {
return m_basePool.Handle2CompactKey(h); }
107 KY_INLINE Handle CompactKey2Handle(Key key)
const {
return m_basePool.CompactKey2Handle(key); }
109 KY_INLINE
KyUInt32 GetChunkCount()
const {
return m_basePool.GetChunkCount(); }
110 KY_INLINE
KyUInt32 GetNbSlotsByChunk()
const {
return m_basePool.GetNbSlotsByChunk(); }
112 KY_INLINE
KyUInt32 Ptr2ChunkIdx(T* ptr)
const {
return m_basePool.Ptr2ChunkIdx(ptr); }
113 KY_INLINE
KyUInt32 Ptr2IdxInChunk(
KyUInt32 chunkIdx, T* ptr)
const {
return m_basePool.Ptr2IdxInChunk(chunkIdx, ptr); }
115 KY_INLINE T& Get(
KyUInt32 chunkIdx,
KyUInt32 idxInChunk)
const {
return m_basePool.Get(chunkIdx, idxInChunk); }
117 KY_INLINE
KyUInt32 GetGlobalIdx(
const Handle& handle) {
return m_basePool.GetGlobalIdx(handle); }
118 KY_INLINE
KyUInt32 GetGlobalIdx(Key key) {
return m_basePool.GetGlobalIdx(key); }
119 KY_INLINE
KyUInt32 GetGlobalIdx(T* ptr) {
return m_basePool.GetGlobalIdx(ptr); }
122 KY_INLINE
bool Next(Iterator& it)
const;
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24