![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <RingBuffer.h>
Public Types | |
| typedef T | ElementType |
| 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 |
Friends | |
| class | FRingBufferTest |
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.
| typedef AllocatorT TRingBuffer< T, AllocatorT >::Allocator |
| using TRingBuffer< T, AllocatorT >::ElementAllocatorType = std::conditional_t< Allocator::NeedsElementType, typename Allocator::template ForElementType<ElementType>, typename Allocator::ForAnyElementType > |
| typedef T TRingBuffer< T, AllocatorT >::ElementType |
Type of the Elements in the container.
| typedef std::make_signed_t<typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::IndexType |
Type used to request values at a given index in the container.
| typedef std::make_unsigned_t<typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::SizeType |
Type used to communicate size and capacity and counts
| typedef TRingBufferIterator<const TRingBuffer, const ElementType, typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::TConstIterator |
| typedef TRingBufferIterator<TRingBuffer, ElementType, typename Allocator::SizeType> TRingBuffer< T, AllocatorT >::TIterator |
Iterator type used for ranged-for traversal.
|
inline |
Construct Empty Queue with capacity 0.
|
inlineexplicit |
Construct Empty Queue with the given initial requested capacity.
|
inline |
Construct a Queue with initial state (from front to back) equal to the given list.
|
inline |
|
inline |
|
inline |
| TRingBuffer< DataType >::TRingBuffer | ( | uint32 | BufferDataSize | ) |
Constructor
| TRingBuffer< T, AllocatorT >::~TRingBuffer | ( | ) |
Default Destructor
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
inline |
begin iterator for ranged-for
|
inline |
begin iterator for const ranged-for
| FORCEINLINE DataType & TRingBuffer< DataType >::Bottom | ( | ) |
| FORCEINLINE const DataType & TRingBuffer< DataType >::Bottom | ( | ) | const |
Gets the first data word in the FIFO (i.e. oldest).
| FORCEINLINE uint32 TRingBuffer< DataType >::BottomIndex | ( | ) | const |
Gets the buffer index that the first data word is stored in.
|
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.
|
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.
| bool TRingBuffer< DataType >::Dequeue | ( | DataType & | ValOut | ) |
Take the next data word from the FIFO buffer.
| OUT | ValOut The variable to receive the data word |
| uint32 TRingBuffer< DataType >::Dequeue | ( | DataType * | ValBuf, |
| const uint32 & | BufLen | ||
| ) |
Take the next set of data words from the FIFO buffer.
| ValBuf | The buffer to receive the data |
| BufLen | The number of words requested |
|
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.
|
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.
|
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.
|
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.
| void TRingBuffer< DataType >::Empty | ( | ) |
Clears memory and indexes
|
inline |
Empty the RingBuffer, destructing any elements and releasing the RingBuffer's storage. Sets the new capacity after release to the given capacity.
|
inline |
end iterator for ranged-for
|
inline |
end iterator for const ranged-for
| void TRingBuffer< DataType >::Enqueue | ( | const DataType & | Val | ) |
Pushes a data word to the end of the FIFO. WILL OVERWRITE OLDEST if full.
| Val | The data word to push |
| 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.
| ValBuf | The buffer pointer |
| BufLen | The length to copy |
|
inline |
Return a reference to the element at the front pointer of the RingBuffer. Invalid to call on an empty RingBuffer.
|
inline |
Return a const reference to the element at the front pointer of the RingBuffer. Invalid to call on an empty RingBuffer.
|
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.
|
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.
|
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.
| void TRingBuffer< DataType >::GetShaHash | ( | FSHAHash & | OutHash | ) | const |
Get the SHA1 hash for the data currently in the FIFO
| OutHash | Receives the SHA hash |
|
inline |
Returns true if the RingBuffer is empty.
|
inline |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array.
|
inline |
Return a reference to the element at the back pointer of the RingBuffer. Invalid to call on an empty RingBuffer.
|
inline |
Return a const reference to the element at the back pointer of the RingBuffer. Invalid to call on an empty RingBuffer.
|
inline |
Current allocated Capacity, note this will always be a power of two, or the special case 0.
|
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.
| FORCEINLINE uint32 TRingBuffer< DataType >::NextIndex | ( | ) | const |
Gets the buffer index that the next enqueued word will get stored in.
|
inline |
Gets the number of elements in the RingBuffer.
|
inline |
|
inline |
|
inline |
|
inline |
| FORCEINLINE DataType & TRingBuffer< DataType >::operator[] | ( | const int32 & | Index | ) |
| 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.
| Index | The index into the FIFO buffer |
|
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.
|
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.
| bool TRingBuffer< DataType >::Peek | ( | DataType & | ValOut | ) | const |
Get the next data word from the FIFO buffer without removing it.
| OUT | ValOut The variable to receive the data word |
| uint32 TRingBuffer< DataType >::Peek | ( | DataType * | ValBuf, |
| const uint32 & | BufLen | ||
| ) | const |
Get the next set of data words from the FIFO buffer without removing them.
| ValBuf | The buffer to receive the data |
| BufLen | The number of words requested |
|
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.
|
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.
|
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.
|
inline |
|
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.
|
inline |
|
inline |
Removes as many instances of Item as there are in the array, maintaining order but not indices.
| Item | Item to remove from array. |
|
inline |
Removes all items for which a given predicate applies, maintaining order but not indices.
| Predicate | Any item for which the predicate returns true is removed. |
|
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.
|
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.
|
inline |
Empty the RingBuffer, destructing any elements in the RingBuffer but not releasing the RingBuffer's storage.
| FORCEINLINE uint32 TRingBuffer< DataType >::RingDataSize | ( | ) | const |
Gets the size of the data buffer.
| FORCEINLINE uint32 TRingBuffer< DataType >::RingDataUsage | ( | ) | const |
Gets the number of words currently in the FIFO.
| int32 TRingBuffer< DataType >::SerialCompare | ( | const DataType * | SerialBuffer, |
| uint32 | CompareLen | ||
| ) | const |
Compare the memory in the FIFO to the memory in the given buffer
| SerialBuffer | The buffer containing data to compare |
| CompareLen | The number of words to compare |
| void TRingBuffer< DataType >::Serialize | ( | DataType * | SerialBuffer | ) | const |
Serializes the internal buffer into the given buffer
| SerialBuffer | A preallocated buffer to copy data into |
|
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.
|
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.
| FORCEINLINE DataType & TRingBuffer< DataType >::Top | ( | ) |
| FORCEINLINE const DataType & TRingBuffer< DataType >::Top | ( | ) | const |
Gets the last data word in the FIFO (i.e. most recently pushed).
| FORCEINLINE uint32 TRingBuffer< DataType >::TopIndex | ( | ) | const |
Gets the buffer index that the last data word is stored in.
| FORCEINLINE uint64 TRingBuffer< DataType >::TotalDataPushed | ( | ) | const |
Gets the total number of words that have been pushed through this buffer since clearing
|
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.
|
friend |