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

#include <ringbuffer.h>

List of all members.

Public Member Functions

void advance (int n=1)
const T & operator[] (int i) const
T & operator[] (int i)
void resize (int size)
 RingBuffer (int size, const T &t)
 RingBuffer (int size=0)
int size () const
 What is the size of the buffer?
 ~RingBuffer ()

Private Attributes

std::vector< T > my_buffer
int my_start

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.


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.

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.

template<typename T >
CVD::RingBuffer< T >::~RingBuffer (  )  [inline]

Definition at line 55 of file ringbuffer.h.


Member Function Documentation

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.

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 >
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 >
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.


Member Data Documentation

template<typename T >
std::vector<T> CVD::RingBuffer< T >::my_buffer [private]

Definition at line 92 of file ringbuffer.h.

template<typename T >
int CVD::RingBuffer< T >::my_start [private]

Definition at line 93 of file ringbuffer.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libcvd
Author(s): Edward Rosten, Paul Smith, Tom Drummond, Gerhard Reitmayr, Ethan Eade, Timothy Gan, Chris Kemp, Georg Klein
autogenerated on Fri Jan 11 09:13:52 2013