XII Release 0.1.0
Loading...
Searching...
No Matches
xiiDataBlock< T, SizeInBytes > Struct Template Reference

Copyright (c) Theophilus Eriata. All Rights Reserved. More...

#include <LargeBlockAllocator.h>

Public Types

enum  { SIZE_IN_BYTES = SizeInBytes , CAPACITY = SIZE_IN_BYTES / sizeof(T) }

Public Member Functions

 XII_DECLARE_POD_TYPE ()
 xiiDataBlock (T *pData, xiiUInt32 uiCount)
 Constructs a data block wrapping the given memory region.
T * ReserveBack ()
T * PopBack ()
bool IsEmpty () const
bool IsFull () const
T & operator[] (xiiUInt32 uiIndex) const
 Provides access to elements by index within the used range.

Public Attributes

T * m_pData
xiiUInt32 m_uiCount

Detailed Description

template<typename T, xiiUInt32 SizeInBytes>
struct xiiDataBlock< T, SizeInBytes >

Copyright (c) Theophilus Eriata. All Rights Reserved.

Represents a typed block of memory with fixed size, typically used for bulk allocations.

This wrapper provides type-safe access to a block of memory that can hold multiple elements of type T. The block has a fixed capacity determined by SizeInBytes and sizeof(T). It tracks the current count of used elements and provides stack-like operations for efficient allocation/deallocation within the block.

Constructor & Destructor Documentation

◆ xiiDataBlock()

template<typename T, xiiUInt32 SizeInBytes>
XII_ALWAYS_INLINE xiiDataBlock< T, SizeInBytes >::xiiDataBlock ( T * pData,
xiiUInt32 uiCount )

Constructs a data block wrapping the given memory region.

Copyright (c) Theophilus Eriata. All Rights Reserved.

Member Function Documentation

◆ PopBack()

template<typename T, xiiUInt32 SizeInBytes>
XII_FORCE_INLINE T * xiiDataBlock< T, SizeInBytes >::PopBack ( )

Removes and returns pointer to the last element in the block.

Returns nullptr if the block is empty.

◆ ReserveBack()

template<typename T, xiiUInt32 SizeInBytes>
XII_FORCE_INLINE T * xiiDataBlock< T, SizeInBytes >::ReserveBack ( )

Reserves space for one element at the end of the block.

Returns pointer to the reserved element, or nullptr if the block is full.


The documentation for this struct was generated from the following files: