Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | TCircularBuffer |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/CircularBuffer.h |
| Include Path | #include "Containers/CircularBuffer.h" |
Syntax
template<typename InElementType>
class TCircularBuffer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TCircularBuffer
(
uint32 Capacity |
Creates and initializes a new instance of the TCircularBuffer class. | Containers/CircularBuffer.h | |
TCircularBuffer
(
uint32 Capacity, |
Creates and initializes a new instance of the TCircularBuffer class. | Containers/CircularBuffer.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | InElementType | Containers/CircularBuffer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Elements | TArray< ElementType > | Holds the buffer's elements. | Containers/CircularBuffer.h | |
| IndexMask | uint32 | Holds the mask for indexing the buffer's elements. | Containers/CircularBuffer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
uint32 Capacity() |
Returns the number of elements that the buffer can hold. | Containers/CircularBuffer.h | |
uint32 GetNextIndex
(
uint32 CurrentIndex |
Calculates the index that follows the given index. | Containers/CircularBuffer.h | |
uint32 GetPreviousIndex
(
uint32 CurrentIndex |
Calculates the index previous to the given index. | Containers/CircularBuffer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ElementType & operator[]
(
uint32 Index |
Returns the mutable element at the specified index. | Containers/CircularBuffer.h | |
const ElementType & operator[]
(
uint32 Index |
Returns the immutable element at the specified index. | Containers/CircularBuffer.h |