Plasma Engine  2.0
Loading...
Searching...
No Matches
plStaticRingBuffer< T, Capacity > Class Template Reference

A ring-buffer container that will use a static array of a given capacity to cycle through elements. More...

#include <StaticRingBuffer.h>

Public Member Functions

 plStaticRingBuffer ()
 Constructs an empty ring-buffer.
 
 plStaticRingBuffer (const plStaticRingBuffer< T, Capacity > &rhs)
 Copies the content from rhs into this ring-buffer.
 
 ~plStaticRingBuffer ()
 Destructs all remaining elements.
 
void operator= (const plStaticRingBuffer< T, Capacity > &rhs)
 Copies the content from rhs into this ring-buffer.
 
bool operator== (const plStaticRingBuffer< T, Capacity > &rhs) const
 Compares two ring-buffers for equality.
 
 PL_ADD_DEFAULT_OPERATOR_NOTEQUAL (const plStaticRingBuffer< T, Capacity > &)
 
void PushBack (const T &element)
 Appends an element at the end of the ring-buffer. Asserts that CanAppend() is true.
 
void PushBack (T &&element)
 Appends an element at the end of the ring-buffer. Asserts that CanAppend() is true.
 
T & PeekBack ()
 Accesses the latest element in the ring-buffer.
 
const T & PeekBack () const
 Accesses the latest element in the ring-buffer.
 
void PopFront (plUInt32 uiElements=1)
 Removes the oldest element from the ring-buffer.
 
const T & PeekFront () const
 Accesses the oldest element in the ring-buffer.
 
T & PeekFront ()
 Accesses the oldest element in the ring-buffer.
 
const T & operator[] (plUInt32 uiIndex) const
 Accesses the n-th element in the ring-buffer.
 
T & operator[] (plUInt32 uiIndex)
 Accesses the n-th element in the ring-buffer.
 
plUInt32 GetCount () const
 Returns the number of elements that are currently in the ring-buffer.
 
bool IsEmpty () const
 Returns true if the ring-buffer currently contains no elements.
 
bool CanAppend (plUInt32 uiElements=1)
 Returns true, if the ring-buffer can store at least uiElements additional elements.
 
void Clear ()
 Destructs all elements in the ring-buffer.
 
const T * GetElements () const
 

Detailed Description

template<typename T, plUInt32 Capacity>
class plStaticRingBuffer< T, Capacity >

A ring-buffer container that will use a static array of a given capacity to cycle through elements.

If you need a dynamic ring-buffer, use an plDeque.


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