UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TRingBuffer< T, AllocatorT > Class Template Reference

#include <RingBuffer.h>

Public Types

typedefElementType
 
typedef AllocatorT Allocator
 
using ElementAllocatorType = std::conditional_t< Allocator::NeedsElementType, typename Allocator::template ForElementType< ElementType >, typename Allocator::ForAnyElementType >
 
typedef std::make_signed_t< typename Allocator::SizeType > IndexType
 
typedef std::make_unsigned_t< typename Allocator::SizeType > SizeType
 
typedef TRingBufferIterator< TRingBuffer, ElementType, typename Allocator::SizeType > TIterator
 
typedef TRingBufferIterator< const TRingBuffer, const ElementType, typename Allocator::SizeType > TConstIterator
 

Public Member Functions

 TRingBuffer ()
 
 TRingBuffer (SizeType InitialCapacity)
 
 TRingBuffer (std::initializer_list< ElementType > InitList)
 
 TRingBuffer (TRingBuffer &&Other)
 
TRingBufferoperator= (TRingBuffer &&Other)
 
 TRingBuffer (const TRingBuffer &Other)
 
TRingBufferoperator= (const TRingBuffer &Other)
 
 ~TRingBuffer ()
 
bool IsEmpty () const
 
IndexType Num () const
 
IndexType Max () const
 
void Reserve (SizeType RequiredCapacity)
 
void Trim ()
 
void Reset ()
 
void Empty (SizeType Capacity=0)
 
IndexType Add (ElementType &&Element)
 
ElementTypeAdd_GetRef (ElementType &&Element)
 
IndexType Add (const ElementType &Element)
 
ElementTypeAdd_GetRef (const ElementType &Element)
 
template<typename... ArgsType>
IndexType Emplace (ArgsType &&... Args)
 
template<typename... ArgsType>
ElementTypeEmplace_GetRef (ArgsType &&... Args)
 
IndexType AddUninitialized ()
 
ElementTypeAddUninitialized_GetRef ()
 
void MoveAppendRange (ElementType *OtherData, SizeType OtherNum)
 
IndexType AddFront (ElementType &&Element)
 
ElementTypeAddFront_GetRef (ElementType &&Element)
 
IndexType AddFront (const ElementType &Element)
 
ElementTypeAddFront_GetRef (const ElementType &Element)
 
template<typename... ArgsType>
IndexType EmplaceFront (ArgsType &&... Args)
 
template<typename... ArgsType>
ElementTypeEmplaceFront_GetRef (ArgsType &&... Args)
 
IndexType AddFrontUninitialized ()
 
ElementTypeAddFrontUninitialized_GetRef ()
 
ElementTypeFirst ()
 
const ElementTypeFirst () const
 
ElementTypeLast ()
 
const ElementTypeLast () const
 
void PopFront (SizeType PopCount=1)
 
void PopFrontNoCheck (SizeType PopCount=1)
 
ElementType PopFrontValue ()
 
void Pop (SizeType PopCount=1)
 
void PopNoCheck (SizeType PopCount=1)
 
ElementType PopValue ()
 
void ShiftIndexToFront (IndexType Index)
 
void ShiftIndexToBack (IndexType Index)
 
TIterator begin ()
 
TConstIterator begin () const
 
TIterator end ()
 
TConstIterator end () const
 
bool IsValidIndex (IndexType Index) const
 
ElementTypeoperator[] (IndexType Index)
 
const ElementTypeoperator[] (IndexType Index) const
 
ElementTypeGetAtIndexNoCheck (IndexType Index)
 
const ElementTypeGetAtIndexNoCheck (IndexType Index) const
 
IndexType ConvertPointerToIndex (const ElementType *Ptr) const
 
void RemoveAt (IndexType Index)
 
SizeType Remove (const ElementType &Item)
 
template<typename PredicateType >
SizeType RemoveAll (PredicateType Predicate)
 
template<typename OtherAllocator >
bool operator== (const TRingBuffer< ElementType, OtherAllocator > &Other) const
 
template<typename OtherAllocator >
bool operator!= (const TRingBuffer< ElementType, OtherAllocator > &Other) const
 
TArrayView< T > Compact ()
 
SIZE_T GetAllocatedSize (void) const
 
 TRingBuffer (uint32 BufferDataSize)
 
 ~TRingBuffer ()
 
void Empty ()
 
void Enqueue (const DataType &Val)
 
void Enqueue (const DataType *ValBuf, const uint32 &BufLen)
 
bool Dequeue (DataType &ValOut)
 
uint32 Dequeue (DataType *ValBuf, const uint32 &BufLen)
 
bool Peek (DataType &ValOut) const
 
uint32 Peek (DataType *ValBuf, const uint32 &BufLen) const
 
int32 SerialCompare (const DataType *SerialBuffer, uint32 CompareLen) const
 
void GetShaHash (FSHAHash &OutHash) const
 
void Serialize (DataType *SerialBuffer) const
 
FORCEINLINE const DataType & operator[] (const int32 &Index) const
 
FORCEINLINE DataType & operator[] (const int32 &Index)
 
FORCEINLINE const DataType & Top () const
 
FORCEINLINE DataType & Top ()
 
FORCEINLINE const DataType & Bottom () const
 
FORCEINLINE DataType & Bottom ()
 
FORCEINLINE uint32 TopIndex () const
 
FORCEINLINE uint32 BottomIndex () const
 
FORCEINLINE uint32 NextIndex () const
 
FORCEINLINE uint32 RingDataSize () const
 
FORCEINLINE uint32 RingDataUsage () const
 
FORCEINLINE uint64 TotalDataPushed () const
 

Friends

class FRingBufferTest
 

Detailed Description

template<typename T, typename AllocatorT = FDefaultAllocator>
class TRingBuffer< T, AllocatorT >

RingBuffer - an array with a Front and Back pointer and with implicit wraparound to the beginning of the array when reaching the end of the array when iterating from Front to Back Useful for providing O(1) push/pop at the end of the array (for Queue or Stack) while still having high cache coherency during iteration. Not thread-safe; caller must ensure there is no simultaneous access from multiple threads.

Implementation Details: Relies on unsigned arithmetics and ever-increasing Front and Back indices to avoid having to store an extra element or maintain explicit empty state. Capacity will always be rounded up to the next power of two, to provide rapid masking of the index.

Member Typedef Documentation

◆ Allocator

template<typename T , typename AllocatorT = FDefaultAllocator>
typedef AllocatorT TRingBuffer< T, AllocatorT >::Allocator

◆ ElementAllocatorType

template<typename T , typename AllocatorT = FDefaultAllocator>
using TRingBuffer< T, AllocatorT >::ElementAllocatorType = std::conditional_t< Allocator::NeedsElementType, typename Allocator::template ForElementType<ElementType>, typename Allocator::ForAnyElementType >

◆ ElementType

template<typename T , typename AllocatorT = FDefaultAllocator>
typedef T TRingBuffer< T, AllocatorT >::ElementType

Type of the Elements in the container.

◆ IndexType

template<typename T , typename AllocatorT = FDefaultAllocator>
typedef std::make_signed_t<typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::IndexType

Type used to request values at a given index in the container.

◆ SizeType

template<typename T , typename AllocatorT = FDefaultAllocator>
typedef std::make_unsigned_t<typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::SizeType

Type used to communicate size and capacity and counts

◆ TConstIterator

template<typename T , typename AllocatorT = FDefaultAllocator>
typedef TRingBufferIterator<const TRingBuffer, const ElementType, typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::TConstIterator

◆ TIterator

Iterator type used for ranged-for traversal.

Constructor & Destructor Documentation

◆ TRingBuffer() [1/6]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::TRingBuffer ( )
inline

Construct Empty Queue with capacity 0.

◆ TRingBuffer() [2/6]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::TRingBuffer ( SizeType  InitialCapacity)
inlineexplicit

Construct Empty Queue with the given initial requested capacity.

◆ TRingBuffer() [3/6]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::TRingBuffer ( std::initializer_list< ElementType InitList)
inline

Construct a Queue with initial state (from front to back) equal to the given list.

◆ TRingBuffer() [4/6]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::TRingBuffer ( TRingBuffer< T, AllocatorT > &&  Other)
inline

◆ TRingBuffer() [5/6]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::TRingBuffer ( const TRingBuffer< T, AllocatorT > &  Other)
inline

◆ ~TRingBuffer() [1/2]

template<typename DataType >
TRingBuffer< DataType >::~TRingBuffer ( )
inline

◆ TRingBuffer() [6/6]

template<typename DataType >
TRingBuffer< DataType >::TRingBuffer ( uint32  BufferDataSize)

Constructor

◆ ~TRingBuffer() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer< T, AllocatorT >::~TRingBuffer ( )

Default Destructor

Member Function Documentation

◆ Add() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::Add ( const ElementType Element)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is copy constructed from the argument. Returns the index to the added element.

◆ Add() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::Add ( ElementType &&  Element)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is move constructed from the argument. Returns the index of the added element.

◆ Add_GetRef() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::Add_GetRef ( const ElementType Element)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is copy constructed from the argument. Returns a reference to the added element.

◆ Add_GetRef() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::Add_GetRef ( ElementType &&  Element)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is move constructed from the argument. Returns a reference to the added element.

◆ AddFront() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::AddFront ( const ElementType Element)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is copy constructed from the argument. Returns the index to the added element.

◆ AddFront() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::AddFront ( ElementType &&  Element)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is move constructed from the argument. Returns the index of the added element.

◆ AddFront_GetRef() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::AddFront_GetRef ( const ElementType Element)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is copy constructed from the argument. Returns a reference to the added element.

◆ AddFront_GetRef() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::AddFront_GetRef ( ElementType &&  Element)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is move constructed from the argument. Returns a reference to the added element.

◆ AddFrontUninitialized()

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::AddFrontUninitialized ( )
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The constructor is not called on the new element and its values in memory are arbitrary. Returns the index to the added element.

◆ AddFrontUninitialized_GetRef()

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::AddFrontUninitialized_GetRef ( )
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The constructor is not called on the new element and its values in memory are arbitrary. Returns a reference to the added element.

◆ AddUninitialized()

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::AddUninitialized ( )
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The constructor is not called on the new element and its values in memory are arbitrary. Returns the index to the added element.

◆ AddUninitialized_GetRef()

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::AddUninitialized_GetRef ( )
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The constructor is not called on the new element and its values in memory are arbitrary. Returns a reference to the added element.

◆ begin() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TIterator TRingBuffer< T, AllocatorT >::begin ( )
inline

begin iterator for ranged-for

◆ begin() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TConstIterator TRingBuffer< T, AllocatorT >::begin ( ) const
inline

begin iterator for const ranged-for

◆ Bottom() [1/2]

template<typename DataType >
FORCEINLINE DataType & TRingBuffer< DataType >::Bottom ( )

◆ Bottom() [2/2]

template<typename DataType >
FORCEINLINE const DataType & TRingBuffer< DataType >::Bottom ( ) const

Gets the first data word in the FIFO (i.e. oldest).

Returns
The first data word

◆ BottomIndex()

template<typename DataType >
FORCEINLINE uint32 TRingBuffer< DataType >::BottomIndex ( ) const

Gets the buffer index that the first data word is stored in.

Returns
The index of Bottom()

◆ Compact()

template<typename T , typename AllocatorT = FDefaultAllocator>
TArrayView< T > TRingBuffer< T, AllocatorT >::Compact ( )
inline

Shift all elements so that the front pointer's location in memory is less than the back pointer's. Returns a temporary ArrayView for the RingBuffer's elements; the returned ArrayView will be invalid after the next write operation on the RingBuffer.

◆ ConvertPointerToIndex()

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::ConvertPointerToIndex ( const ElementType Ptr) const
inline

Given a pointer to an Element anywhere in memory, return the index of the element in the RingBuffer, or INDEX_NONE if it is not present.

◆ Dequeue() [1/2]

template<typename DataType >
bool TRingBuffer< DataType >::Dequeue ( DataType &  ValOut)

Take the next data word from the FIFO buffer.

Parameters
OUTValOut The variable to receive the data word
Returns
true if the buffer was not empty, false otherwise.

◆ Dequeue() [2/2]

template<typename DataType >
uint32 TRingBuffer< DataType >::Dequeue ( DataType *  ValBuf,
const uint32 BufLen 
)

Take the next set of data words from the FIFO buffer.

Parameters
ValBufThe buffer to receive the data
BufLenThe number of words requested
Returns
the number of words actually copied

◆ Emplace()

template<typename T , typename AllocatorT = FDefaultAllocator>
template<typename... ArgsType>
IndexType TRingBuffer< T, AllocatorT >::Emplace ( ArgsType &&...  Args)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is constructed from the given arguments. Returns the index to the added element.

◆ Emplace_GetRef()

template<typename T , typename AllocatorT = FDefaultAllocator>
template<typename... ArgsType>
ElementType & TRingBuffer< T, AllocatorT >::Emplace_GetRef ( ArgsType &&...  Args)
inline

Add a new element after the back pointer of the RingBuffer, resizing if necessary. The new element is constructed from the given arguments. Returns a reference to the added element.

◆ EmplaceFront()

template<typename T , typename AllocatorT = FDefaultAllocator>
template<typename... ArgsType>
IndexType TRingBuffer< T, AllocatorT >::EmplaceFront ( ArgsType &&...  Args)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is constructed from the given arguments. Returns the index to the added element.

◆ EmplaceFront_GetRef()

template<typename T , typename AllocatorT = FDefaultAllocator>
template<typename... ArgsType>
ElementType & TRingBuffer< T, AllocatorT >::EmplaceFront_GetRef ( ArgsType &&...  Args)
inline

Add a new element before the front pointer of the RingBuffer, resizing if necessary. The new element is constructed from the given arguments. Returns a reference to the added element.

◆ Empty() [1/2]

template<typename DataType >
void TRingBuffer< DataType >::Empty ( )

Clears memory and indexes

◆ Empty() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::Empty ( SizeType  Capacity = 0)
inline

Empty the RingBuffer, destructing any elements and releasing the RingBuffer's storage. Sets the new capacity after release to the given capacity.

◆ end() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TIterator TRingBuffer< T, AllocatorT >::end ( )
inline

end iterator for ranged-for

◆ end() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TConstIterator TRingBuffer< T, AllocatorT >::end ( ) const
inline

end iterator for const ranged-for

◆ Enqueue() [1/2]

template<typename DataType >
void TRingBuffer< DataType >::Enqueue ( const DataType &  Val)

Pushes a data word to the end of the FIFO. WILL OVERWRITE OLDEST if full.

Parameters
ValThe data word to push

◆ Enqueue() [2/2]

template<typename DataType >
void TRingBuffer< DataType >::Enqueue ( const DataType *  ValBuf,
const uint32 BufLen 
)

Pushes a buffer of data words to the end of the FIFO. WILL OVERWRITE OLDEST if full.

Parameters
ValBufThe buffer pointer
BufLenThe length to copy

◆ First() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::First ( )
inline

Return a reference to the element at the front pointer of the RingBuffer. Invalid to call on an empty RingBuffer.

◆ First() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
const ElementType & TRingBuffer< T, AllocatorT >::First ( ) const
inline

Return a const reference to the element at the front pointer of the RingBuffer. Invalid to call on an empty RingBuffer.

◆ GetAllocatedSize()

template<typename T , typename AllocatorT = FDefaultAllocator>
SIZE_T TRingBuffer< T, AllocatorT >::GetAllocatedSize ( void  ) const
inline

Helper function to return the amount of memory allocated by this container. Only returns the size of allocations made directly by the container, not the elements themselves.

Returns
Number of bytes allocated by this container.

◆ GetAtIndexNoCheck() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::GetAtIndexNoCheck ( IndexType  Index)
inline

Unsafely return a writable reference to the value at the given Index. Invalid to call (and does not warn) with an index less than 0 or greater than or equal to the number of elements in the RingBuffer.

◆ GetAtIndexNoCheck() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
const ElementType & TRingBuffer< T, AllocatorT >::GetAtIndexNoCheck ( IndexType  Index) const
inline

Unsafely return a const reference to the value at the given Index. Invalid to call (and does not warn) with an index less than 0 or greater than or equal to the number of elements in the RingBuffer.

◆ GetShaHash()

template<typename DataType >
void TRingBuffer< DataType >::GetShaHash ( FSHAHash OutHash) const

Get the SHA1 hash for the data currently in the FIFO

Parameters
OutHashReceives the SHA hash

◆ IsEmpty()

template<typename T , typename AllocatorT = FDefaultAllocator>
bool TRingBuffer< T, AllocatorT >::IsEmpty ( ) const
inline

Returns true if the RingBuffer is empty.

◆ IsValidIndex()

template<typename T , typename AllocatorT = FDefaultAllocator>
bool TRingBuffer< T, AllocatorT >::IsValidIndex ( IndexType  Index) const
inline

Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array.

◆ Last() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::Last ( )
inline

Return a reference to the element at the back pointer of the RingBuffer. Invalid to call on an empty RingBuffer.

◆ Last() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
const ElementType & TRingBuffer< T, AllocatorT >::Last ( ) const
inline

Return a const reference to the element at the back pointer of the RingBuffer. Invalid to call on an empty RingBuffer.

◆ Max()

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::Max ( ) const
inline

Current allocated Capacity, note this will always be a power of two, or the special case 0.

◆ MoveAppendRange()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::MoveAppendRange ( ElementType OtherData,
SizeType  OtherNum 
)
inline

Append elements from a range onto the back pointer of the RingBuffer, resizing if necessary. Each element is move-constructed into the RingBuffer; source elements may therefore be modified.

◆ NextIndex()

template<typename DataType >
FORCEINLINE uint32 TRingBuffer< DataType >::NextIndex ( ) const

Gets the buffer index that the next enqueued word will get stored in.

Returns
The index that the next enqueued word will have

◆ Num()

template<typename T , typename AllocatorT = FDefaultAllocator>
IndexType TRingBuffer< T, AllocatorT >::Num ( ) const
inline

Gets the number of elements in the RingBuffer.

◆ operator!=()

template<typename T , typename AllocatorT = FDefaultAllocator>
bool TRingBuffer< T, AllocatorT >::operator!= ( const TRingBuffer< ElementType, OtherAllocator > &  Other) const
inline

◆ operator=() [1/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer & TRingBuffer< T, AllocatorT >::operator= ( const TRingBuffer< T, AllocatorT > &  Other)
inline

◆ operator=() [2/2]

template<typename T , typename AllocatorT = FDefaultAllocator>
TRingBuffer & TRingBuffer< T, AllocatorT >::operator= ( TRingBuffer< T, AllocatorT > &&  Other)
inline

◆ operator==()

template<typename T , typename AllocatorT = FDefaultAllocator>
bool TRingBuffer< T, AllocatorT >::operator== ( const TRingBuffer< ElementType, OtherAllocator > &  Other) const
inline

◆ operator[]() [1/4]

template<typename DataType >
FORCEINLINE DataType & TRingBuffer< DataType >::operator[] ( const int32 Index)

◆ operator[]() [2/4]

template<typename DataType >
FORCEINLINE const DataType & TRingBuffer< DataType >::operator[] ( const int32 Index) const

Square bracket operators for accessing data in the buffer by FIFO index. [0] returns the next entry in the FIFO that would get provided by Dequeue or Peek.

Parameters
IndexThe index into the FIFO buffer
Returns
The data word

◆ operator[]() [3/4]

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType & TRingBuffer< T, AllocatorT >::operator[] ( IndexType  Index)
inline

Return a writable reference to the value at the given Index. Invalid to call with an index less than 0 or greater than or equal to the number of elements in the RingBuffer.

◆ operator[]() [4/4]

template<typename T , typename AllocatorT = FDefaultAllocator>
const ElementType & TRingBuffer< T, AllocatorT >::operator[] ( IndexType  Index) const
inline

Return a const reference to the value at the given Index. Invalid to call with an index less than 0 or greater than or equal to the number of elements in the RingBuffer.

◆ Peek() [1/2]

template<typename DataType >
bool TRingBuffer< DataType >::Peek ( DataType &  ValOut) const

Get the next data word from the FIFO buffer without removing it.

Parameters
OUTValOut The variable to receive the data word
Returns
true if the buffer was not empty, false otherwise.

◆ Peek() [2/2]

template<typename DataType >
uint32 TRingBuffer< DataType >::Peek ( DataType *  ValBuf,
const uint32 BufLen 
) const

Get the next set of data words from the FIFO buffer without removing them.

Parameters
ValBufThe buffer to receive the data
BufLenThe number of words requested
Returns
the number of words actually copied

◆ Pop()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::Pop ( SizeType  PopCount = 1)
inline

Pop the given number of arguments (default: 1) from the back pointer of the RingBuffer. Invalid to call with a number of elements greater than the current number of elements in the RingBuffer.

◆ PopFront()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::PopFront ( SizeType  PopCount = 1)
inline

Pop the given number of elements (default: 1) from the front pointer of the RingBuffer. Invalid to call with a number of elements greater than the current number of elements in the RingBuffer.

◆ PopFrontNoCheck()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::PopFrontNoCheck ( SizeType  PopCount = 1)
inline

Unsafely pop the given number of arguments (default: 1) from the front pointer of the RingBuffer. Invalid to call (and does not warn) with a number of elements greater than the current number of elements in the RingBuffer.

◆ PopFrontValue()

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType TRingBuffer< T, AllocatorT >::PopFrontValue ( )
inline

◆ PopNoCheck()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::PopNoCheck ( SizeType  PopCount = 1)
inline

Pop the given number of elements (default: 1) from the back pointer of the RingBuffer. Invalid to call (and does not warn) with a number of elements greater than the current number of elements in the RingBuffer.

◆ PopValue()

template<typename T , typename AllocatorT = FDefaultAllocator>
ElementType TRingBuffer< T, AllocatorT >::PopValue ( )
inline

◆ Remove()

template<typename T , typename AllocatorT = FDefaultAllocator>
SizeType TRingBuffer< T, AllocatorT >::Remove ( const ElementType Item)
inline

Removes as many instances of Item as there are in the array, maintaining order but not indices.

Parameters
ItemItem to remove from array.
Returns
Number of removed elements.

◆ RemoveAll()

template<typename T , typename AllocatorT = FDefaultAllocator>
template<typename PredicateType >
SizeType TRingBuffer< T, AllocatorT >::RemoveAll ( PredicateType  Predicate)
inline

Removes all items for which a given predicate applies, maintaining order but not indices.

Parameters
PredicateAny item for which the predicate returns true is removed.
Returns
Number of removed elements.

◆ RemoveAt()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::RemoveAt ( IndexType  Index)
inline

Remove the value at the given index from the RingBuffer, and shift values ahead or behind it into its location to fill the hole. It is valid to call with Index outside the range of the array; does nothing in that case.

◆ Reserve()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::Reserve ( SizeType  RequiredCapacity)
inline

Set the capacity to the maximum of the current capacity and the (next power of two greater than or equal to) the given capacity.

◆ Reset()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::Reset ( )
inline

Empty the RingBuffer, destructing any elements in the RingBuffer but not releasing the RingBuffer's storage.

◆ RingDataSize()

template<typename DataType >
FORCEINLINE uint32 TRingBuffer< DataType >::RingDataSize ( ) const

Gets the size of the data buffer.

Returns
Template arg BufferDataSize

◆ RingDataUsage()

template<typename DataType >
FORCEINLINE uint32 TRingBuffer< DataType >::RingDataUsage ( ) const

Gets the number of words currently in the FIFO.

Returns
data size

◆ SerialCompare()

template<typename DataType >
int32 TRingBuffer< DataType >::SerialCompare ( const DataType *  SerialBuffer,
uint32  CompareLen 
) const

Compare the memory in the FIFO to the memory in the given buffer

Parameters
SerialBufferThe buffer containing data to compare
CompareLenThe number of words to compare
Returns
< 0 if data < SerialBuffer.. 0 if data == SerialBuffer... > 0 if data > SerialBuffer

◆ Serialize()

template<typename DataType >
void TRingBuffer< DataType >::Serialize ( DataType *  SerialBuffer) const

Serializes the internal buffer into the given buffer

Parameters
SerialBufferA preallocated buffer to copy data into

◆ ShiftIndexToBack()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::ShiftIndexToBack ( IndexType  Index)
inline

Move the value at the given index into the back pointer of the RingBuffer, and shift all elements behind of it up by one to make room for it. Invalid to call with an index less than 0 or greater than or equal to the number of elements in the RingBuffer.

◆ ShiftIndexToFront()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::ShiftIndexToFront ( IndexType  Index)
inline

Move the value at the given index into the front pointer of the RingBuffer, and shift all elements ahead of it down by one to make room for it. Invalid to call with a negative index or index greater than the number of elements in the RingBuffer.

◆ Top() [1/2]

template<typename DataType >
FORCEINLINE DataType & TRingBuffer< DataType >::Top ( )

◆ Top() [2/2]

template<typename DataType >
FORCEINLINE const DataType & TRingBuffer< DataType >::Top ( ) const

Gets the last data word in the FIFO (i.e. most recently pushed).

Returns
The last data word

◆ TopIndex()

template<typename DataType >
FORCEINLINE uint32 TRingBuffer< DataType >::TopIndex ( ) const

Gets the buffer index that the last data word is stored in.

Returns
The index of Top()

◆ TotalDataPushed()

template<typename DataType >
FORCEINLINE uint64 TRingBuffer< DataType >::TotalDataPushed ( ) const

Gets the total number of words that have been pushed through this buffer since clearing

Returns
total length of data passed through

◆ Trim()

template<typename T , typename AllocatorT = FDefaultAllocator>
void TRingBuffer< T, AllocatorT >::Trim ( )
inline

Set the capacity to the minimum power of two (or 0) greater than or equal to the current number of elements in the RingBuffer.

Friends And Related Symbol Documentation

◆ FRingBufferTest

template<typename T , typename AllocatorT = FDefaultAllocator>
friend class FRingBufferTest
friend

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