The Nebula Device 3: Util::RingBuffer< TYPE > Class Template Reference

The Nebula Device 3

Util::RingBuffer< TYPE > Class Template Reference

#include <ringbuffer.h>


Detailed Description

template<class TYPE>
class Util::RingBuffer< TYPE >

A ring buffer stores up to a maximum number of elements in a circular fashion. If the buffer is full, the newest element overwrites the oldest element.

(C) 2008 Radon Labs GmbH


Public Member Functions

 RingBuffer ()
 default constructor
 RingBuffer (SizeT capacity)
 constructor with size
 RingBuffer (const RingBuffer< TYPE > &rhs)
 copy constructor
 ~RingBuffer ()
 destructor
void operator= (const RingBuffer< TYPE > &rhs)
 assignment operator
TYPE & operator[] (IndexT index) const
 index operator
void SetCapacity (SizeT newCapacity)
 set capacity (clear previous content)
SizeT Capacity () const
 get capacity
SizeT Size () const
 get number of elements in ring buffer
void Add (const TYPE &elm)
 add an element to the ring buffer
bool IsEmpty () const
 return true if ring buffer is empty
void Reset ()
 reset ring buffer, just reset the head/base indices without calling destructors
TYPE & Front () const
 return reference to first element
TYPE & Back () const
 return reference to last element
Array< TYPE > AsArray () const
 return all values as array
TYPE * GetBuffer ()
 get real linear underlying buffer
const TYPE * GetBuffer () const
 get real linear underlying buffer