ezEngine  Milestone 7
ezStaticRingBuffer< 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

 EZ_CHECK_AT_COMPILETIME_MSG (Capacity > 1,"ORLY?")
 
 ezStaticRingBuffer ()
 Constructs an empty ring-buffer.
 
 ezStaticRingBuffer (const ezStaticRingBuffer< T, Capacity > &rhs)
 Copies the content from rhs into this ring-buffer.
 
 ~ezStaticRingBuffer ()
 Destructs all remaining elements.
 
void operator= (const ezStaticRingBuffer< T, Capacity > &rhs)
 Copies the content from rhs into this ring-buffer.
 
bool operator== (const ezStaticRingBuffer< T, Capacity > &rhs) const
 Compares two ring-buffers for equality.
 
bool operator!= (const ezStaticRingBuffer< T, Capacity > &rhs) const
 Compares two ring-buffers for inequality.
 
void PushBack (const T &element)
 Appends an element at the end of the ring-buffer.
 
void PopFront (ezUInt32 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[] (ezUInt32 uiIndex) const
 Accesses the n-th element in the ring-buffer.
 
T & operator[] (ezUInt32 uiIndex)
 Accesses the n-th element in the ring-buffer.
 
ezUInt32 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 (ezUInt32 uiElements=1)
 Returns true, if there the ring-buffer can store at least uiElements additional elements.
 
void Clear ()
 Destructs all elements in the ring-buffer.
 

Public Attributes

ezUInt8 m_Data [Capacity *sizeof(T)]
 

Private Member Functions

T * GetStaticArray ()
 

Private Attributes

T * m_pElements
 
ezUInt32 m_uiCount
 
ezUInt32 m_uiFirstElement
 

Detailed Description

template<typename T, ezUInt32 Capacity>
class ezStaticRingBuffer< 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 ezDeque.


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