UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TCircularBuffer< InElementType > Class Template Reference

#include <CircularBuffer.h>

Public Types

using ElementType = InElementType
 

Public Member Functions

 TCircularBuffer (uint32 Capacity)
 
 TCircularBuffer (uint32 Capacity, const ElementType &InitialValue)
 
UE_FORCEINLINE_HINT ElementTypeoperator[] (uint32 Index)
 
UE_FORCEINLINE_HINT const ElementTypeoperator[] (uint32 Index) const
 
UE_FORCEINLINE_HINT uint32 Capacity () const
 
UE_FORCEINLINE_HINT uint32 GetNextIndex (uint32 CurrentIndex) const
 
UE_FORCEINLINE_HINT uint32 GetPreviousIndex (uint32 CurrentIndex) const
 

Detailed Description

template<typename InElementType>
class TCircularBuffer< InElementType >

Template for circular buffers.

The size of the buffer is rounded up to the next power of two in order speed up indexing operations using a simple bit mask instead of the commonly used modulus operator that may be slow on some platforms.

Member Typedef Documentation

◆ ElementType

Constructor & Destructor Documentation

◆ TCircularBuffer() [1/2]

template<typename InElementType >
TCircularBuffer< InElementType >::TCircularBuffer ( uint32  Capacity)
inlineexplicit

Creates and initializes a new instance of the TCircularBuffer class.

Parameters
CapacityThe number of elements that the buffer can store (will be rounded up to the next power of 2).

◆ TCircularBuffer() [2/2]

template<typename InElementType >
TCircularBuffer< InElementType >::TCircularBuffer ( uint32  Capacity,
const ElementType InitialValue 
)
inline

Creates and initializes a new instance of the TCircularBuffer class.

Parameters
CapacityThe number of elements that the buffer can store (will be rounded up to the next power of 2).
InitialValueThe initial value for the buffer's elements.

Member Function Documentation

◆ Capacity()

Returns the number of elements that the buffer can hold.

Returns
Buffer capacity.

◆ GetNextIndex()

template<typename InElementType >
UE_FORCEINLINE_HINT uint32 TCircularBuffer< InElementType >::GetNextIndex ( uint32  CurrentIndex) const
inline

Calculates the index that follows the given index.

Parameters
CurrentIndexThe current index.
Returns
The next index.

◆ GetPreviousIndex()

template<typename InElementType >
UE_FORCEINLINE_HINT uint32 TCircularBuffer< InElementType >::GetPreviousIndex ( uint32  CurrentIndex) const
inline

Calculates the index previous to the given index.

Parameters
CurrentIndexThe current index.
Returns
The previous index.

◆ operator[]() [1/2]

Returns the mutable element at the specified index.

Parameters
IndexThe index of the element to return.

◆ operator[]() [2/2]

template<typename InElementType >
UE_FORCEINLINE_HINT const ElementType & TCircularBuffer< InElementType >::operator[] ( uint32  Index) const
inline

Returns the immutable element at the specified index.

Parameters
IndexThe index of the element to return.

The documentation for this class was generated from the following file: