Public Member Functions | Private Types | Private Member Functions | Private Attributes

circular_buffer_t< T > Class Template Reference
[Utility Library]

Simple circular buffer. More...

#include <circular.h>

List of all members.

Public Member Functions

 circular_buffer_t (IN int size)
void addSample (IN const T &t)
int size (void) const throw ()
const T & getSample (IN int idx) const throw ()
 idx = 0 is the oldest sample, always
T & getSample (IN int idx) throw ()
 idx = 0 is the oldest sample, always

Private Types

typedef std::vector< T > vec_type_t

Private Member Functions

int getActualIndex (IN int idx) const throw ()

Private Attributes

vec_type_t m_buffer
int m_max
 
  • max allowed size

int m_idx
 
  • current index

int m_size
 
  • current size


Detailed Description

template<class T>
class circular_buffer_t< T >

Simple circular buffer.

You can repeatedly add samples, and this class will keep only the most current N samples in the buffer. You can ask for the number of samples in the buffer, and iterate through them. Starting at index 0 means you will always walk forward from the oldest to the newest sample in the buffer.

Definition at line 45 of file circular.h.


Member Typedef Documentation

template<class T>
typedef std::vector<T> circular_buffer_t< T >::vec_type_t [private]

Definition at line 84 of file circular.h.


Constructor & Destructor Documentation

template<class T>
circular_buffer_t< T >::circular_buffer_t ( IN int  size  )  [inline]

Definition at line 48 of file circular.h.


Member Function Documentation

template<class T>
void circular_buffer_t< T >::addSample ( IN const T &  t  )  [inline]

Definition at line 57 of file circular.h.

template<class T>
int circular_buffer_t< T >::size ( void   )  const throw () [inline]

Definition at line 69 of file circular.h.

template<class T>
const T& circular_buffer_t< T >::getSample ( IN int  idx  )  const throw () [inline]

idx = 0 is the oldest sample, always

Definition at line 72 of file circular.h.

template<class T>
T& circular_buffer_t< T >::getSample ( IN int  idx  )  throw () [inline]

idx = 0 is the oldest sample, always

Definition at line 78 of file circular.h.

template<class T>
int circular_buffer_t< T >::getActualIndex ( IN int  idx  )  const throw () [inline, private]

Definition at line 86 of file circular.h.


Member Data Documentation

template<class T>
vec_type_t circular_buffer_t< T >::m_buffer [private]

Definition at line 97 of file circular.h.

template<class T>
int circular_buffer_t< T >::m_max [private]

  • max allowed size

Definition at line 98 of file circular.h.

template<class T>
int circular_buffer_t< T >::m_idx [private]

  • current index

Definition at line 99 of file circular.h.

template<class T>
int circular_buffer_t< T >::m_size [private]

  • current size

Definition at line 100 of file circular.h.


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