CVD::RingBuffer< T > Class Template Reference
[General C++ and system helper functions]

#include <ringbuffer.h>

List of all members.


Detailed Description

template<typename T>
class CVD::RingBuffer< T >

Implements a ringbuffer based on std::vector.

A ringbuffer is a circular buffer i.e. once the end of the buffer is reached, reading or writing continues from the start of the buffer. The buffer maintains a notion of a 'current' element, which is buffer[0], and one can access elements before this or after this (using [-n] or [n] respectively), as well as advancing the current element slot by calling advance()

Parameters:
T The data type held by the buffer

Definition at line 38 of file ringbuffer.h.


Public Member Functions

 RingBuffer (int size=0)
 RingBuffer (int size, const T &t)
 ~RingBuffer ()
void resize (int size)
int size () const
T & operator[] (int i)
const T & operator[] (int i) const
void advance (int n=1)

Constructor & Destructor Documentation

template<typename T>
CVD::RingBuffer< T >::RingBuffer ( int  size = 0  )  [inline]

Constructor.

Parameters:
size The size of the ringbuffer

Definition at line 42 of file ringbuffer.h.

References CVD::RingBuffer< T >::size().

template<typename T>
CVD::RingBuffer< T >::RingBuffer ( int  size,
const T &  t 
) [inline]

Constructor.

Parameters:
size The size of the ringbuffer
t The default value for all elements in the ringbuffer

Definition at line 50 of file ringbuffer.h.


Member Function Documentation

template<typename T>
void CVD::RingBuffer< T >::resize ( int  size  )  [inline]

Resize the buffer.

Parameters:
size The size of the ringbuffer

Definition at line 60 of file ringbuffer.h.

template<typename T>
int CVD::RingBuffer< T >::size (  )  const [inline]

What is the size of the buffer?

Definition at line 65 of file ringbuffer.h.

Referenced by CVD::RingBuffer< T >::RingBuffer().

template<typename T>
T& CVD::RingBuffer< T >::operator[] ( int  i  )  [inline]

Access an element from the ringbuffer.

The [0] element is the current element, and one can use [-n] to access previous values in the ringbuffer (up to a limit of -size(), naturally).

Parameters:
i The element number

Definition at line 73 of file ringbuffer.h.

template<typename T>
const T& CVD::RingBuffer< T >::operator[] ( int  i  )  const [inline]

Access an element from the ringbuffer.

The [0] element is the current element, and one can use [-n] to access previous values in the ringbuffer (up to a limit of -size(), naturally).

Parameters:
i The element number

Definition at line 81 of file ringbuffer.h.

template<typename T>
void CVD::RingBuffer< T >::advance ( int  n = 1  )  [inline]

Step the current element on by one.

Parameters:
n The number of slots to advance by (default is 1)

Definition at line 87 of file ringbuffer.h.


The documentation for this class was generated from the following file:
Generated on Wed Feb 18 10:23:08 2009 for CVD by  doxygen 1.5.3