ezEngine Release 26.3
Loading...
Searching...
No Matches
ezDataBlock< T, SizeInBytes > Struct Template Reference

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

#include <LargeBlockAllocator.h>

Public Types

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

Public Member Functions

 EZ_DECLARE_POD_TYPE ()
 
 ezDataBlock (T *pData, ezUInt32 uiCount)
 Constructs a data block wrapping the given memory region.
 
T * ReserveBack ()
 Reserves space for one element at the end of the block.
 
T * PopBack ()
 Removes and returns pointer to the last element in the block.
 
bool IsEmpty () const
 
bool IsFull () const
 
T & operator[] (ezUInt32 uiIndex) const
 Provides access to elements by index within the used range.
 

Public Attributes

T * m_pData
 
ezUInt32 m_uiCount
 

Detailed Description

template<typename T, ezUInt32 SizeInBytes>
struct ezDataBlock< T, SizeInBytes >

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.

Member Function Documentation

◆ PopBack()

template<typename T , ezUInt32 SizeInBytes>
EZ_FORCE_INLINE T * ezDataBlock< 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 , ezUInt32 SizeInBytes>
EZ_FORCE_INLINE T * ezDataBlock< 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: