XII Release 0.1.0
Loading...
Searching...
No Matches
xiiBlockStorage< T, BlockSizeInByte, StorageType > Class Template Reference

#include <BlockStorage.h>

Classes

class  ConstIterator
class  Iterator

Public Member Functions

 xiiBlockStorage (xiiLargeBlockAllocator< BlockSizeInByte > *pBlockAllocator, xiiAllocator *pAllocator)
void Clear ()
 Removes all objects and deallocates all blocks.
T * Create ()
void Delete (T *pObject)
 Deletes the specified object.
void Delete (T *pObject, T *&out_pMovedObject)
xiiUInt32 GetCount () const
 Returns the total number of objects currently stored.
Iterator GetIterator (xiiUInt32 uiStartIndex=0, xiiUInt32 uiCount=xiiInvalidIndex)
 Returns an iterator for traversing objects in a specified range.
ConstIterator GetIterator (xiiUInt32 uiStartIndex=0, xiiUInt32 uiCount=xiiInvalidIndex) const
 Returns a const iterator for traversing objects in a specified range.

Detailed Description

template<typename T, xiiUInt32 BlockSizeInByte, xiiBlockStorageType::Enum StorageType>
class xiiBlockStorage< T, BlockSizeInByte, StorageType >

High-performance container for objects with pluggable storage strategies.

This container manages objects in blocks of memory, using different strategies for handling gaps when objects are removed. It's designed for scenarios where you need fast allocation and deallocation of many objects, with the choice between compact memory layout or stable object addressing.

Storage strategies:

  • Compact: Moves the last element to fill gaps when objects are deleted, maintaining contiguous memory but invalidating iterators and pointers to moved objects
  • FreeList: Uses a free list to reuse deleted slots, preserving object positions but potentially creating memory fragmentation.

Member Function Documentation

◆ Create()

template<typename T, xiiUInt32 BlockSize, xiiBlockStorageType::Enum StorageType>
T * xiiBlockStorage< T, BlockSize, StorageType >::Create ( )

Creates a new object and returns a pointer to it.

The object is default-constructed. Returns nullptr if allocation fails.

◆ Delete()

template<typename T, xiiUInt32 BlockSize, xiiBlockStorageType::Enum StorageType>
void xiiBlockStorage< T, BlockSize, StorageType >::Delete ( T * pObject,
T *& out_pMovedObject )

Deletes the specified object and reports any moved object.

For Compact storage, if another object is moved to fill the gap, out_pMovedObject will point to the moved object's new location. For FreeList storage, out_pMovedObject is always set to nullptr.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/BlockStorage.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/Implementation/BlockStorage_inl.h