UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::TimeManagement::TModuloCircularBuffer< T, TAllocator > Class Template Reference

#include <ModuloCircularBuffer.h>

Public Member Functions

 TModuloCircularBuffer (SIZE_T InNumSamples)
 
void Add (const T &InItem)
 
const T * GetNextReplacedItem () const
 
SIZE_T Capacity () const
 
SIZE_T Num () const
 
bool IsEmpty () const
 
bool IsFull () const
 
TConstArrayView< T > AsUnorderedView () const
 

Detailed Description

template<typename T, typename TAllocator = FDefaultAllocator>
class UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >

A circular buffer of any size (opposed to TCircularBuffer which requires power of 2).

The next index is computed using the modulo operation: NextIndexToInsert = (NextIndexToInsert + 1) % Data.Num(). It's less performant than bitmasking, which TCircularBuffer uses, but does not require any specific element count.

Constructor & Destructor Documentation

◆ TModuloCircularBuffer()

template<typename T , typename TAllocator = FDefaultAllocator>
UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::TModuloCircularBuffer ( SIZE_T  InNumSamples)
inlineexplicit

Member Function Documentation

◆ Add()

template<typename T , typename TAllocator = FDefaultAllocator>
void UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::Add ( const T &  InItem)
inline

Adds an item to the buffer. If the buffer is full, the oldest item is replaced.

◆ AsUnorderedView()

template<typename T , typename TAllocator = FDefaultAllocator>
TConstArrayView< T > UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::AsUnorderedView ( ) const
inline
Returns
A view into the data. Unordered here it does not represent the order in which items were added. This is useful if you want to sum up all entries, etc.

◆ Capacity()

template<typename T , typename TAllocator = FDefaultAllocator>
SIZE_T UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::Capacity ( ) const
inline
Returns
The number of items that can be stored in this buffer.

◆ GetNextReplacedItem()

template<typename T , typename TAllocator = FDefaultAllocator>
const T * UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::GetNextReplacedItem ( ) const
inline
Returns
Pointer to the item that is replaced with the next Add call. If no item is replaced, then

◆ IsEmpty()

template<typename T , typename TAllocator = FDefaultAllocator>
bool UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::IsEmpty ( ) const
inline
Returns
Whether nothing has ever been added.

◆ IsFull()

template<typename T , typename TAllocator = FDefaultAllocator>
bool UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::IsFull ( ) const
inline
Returns
Whether the buffer is full, i.e. add an item will override an item.

◆ Num()

template<typename T , typename TAllocator = FDefaultAllocator>
SIZE_T UE::TimeManagement::TModuloCircularBuffer< T, TAllocator >::Num ( ) const
inline
Returns
The number of items in the buffer so far.

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