Simple circular buffer. More...
#include <circular.h>
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 |
| |
int | m_idx |
| |
int | m_size |
|
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.
typedef std::vector<T> circular_buffer_t< T >::vec_type_t [private] |
Definition at line 84 of file circular.h.
circular_buffer_t< T >::circular_buffer_t | ( | IN int | size | ) | [inline] |
Definition at line 48 of file circular.h.
void circular_buffer_t< T >::addSample | ( | IN const T & | t | ) | [inline] |
Definition at line 57 of file circular.h.
int circular_buffer_t< T >::size | ( | void | ) | const throw () [inline] |
Definition at line 69 of file circular.h.
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.
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.
int circular_buffer_t< T >::getActualIndex | ( | IN int | idx | ) | const throw () [inline, private] |
Definition at line 86 of file circular.h.
vec_type_t circular_buffer_t< T >::m_buffer [private] |
Definition at line 97 of file circular.h.
int circular_buffer_t< T >::m_max [private] |
Definition at line 98 of file circular.h.
int circular_buffer_t< T >::m_idx [private] |
Definition at line 99 of file circular.h.
int circular_buffer_t< T >::m_size [private] |
Definition at line 100 of file circular.h.