CHROMA
Classes | Public Member Functions | Private Attributes | List of all members

Circular Buffer. More...

#include <circular_buffer.h>

Classes

struct  OutOfBoundsException
 

Public Member Functions

 CircularBuffer (int n_max)
 Constructor. More...
 
 ~CircularBuffer ()
 Destructor is automatic. More...
 
 CircularBuffer (const CircularBuffer< T > &c)
 Copy constructor. More...
 
void reset (void)
 Nuke it: More...
 
int sizeMax (void) const
 Get the maximum number of data items one can store. More...
 
int size (void) const
 Get the current number of items stored. More...
 
void get (const unsigned int i, T &x) const
 get the ith most recent item More...
 
const Toperator[] (int i) const
 
Toperator[] (int i)
 
bool isEmpty (void) const
 Is empty check. More...
 
void push (const T &e)
 push in an item as most recent. More...
 
void replaceHead (const T &x)
 

Private Attributes

unsigned int size_max
 
unsigned int size_internal
 
multi1d< Tq
 
unsigned int start
 
unsigned int end
 

Detailed Description

template<typename T>
class Chroma::CircularBuffer< T >

Circular Buffer.

Definitions for a templated circular buffer class to be used in Chronological Predictor.

Usage: construct with CircularBuffer(int n_max)
with n_max the maximum number of elements – this allocates storage

add elements with push(elem);

reset with reset()

Access elements using operator[unsigned int i]

i=0 most recent i=1 next most rcent ... i=size()-1 // least recent

Definition at line 38 of file circular_buffer.h.

Constructor & Destructor Documentation

◆ CircularBuffer() [1/2]

template<typename T >
Chroma::CircularBuffer< T >::CircularBuffer ( int  n_max)
inline

Constructor.

Definition at line 53 of file circular_buffer.h.

References q.

◆ ~CircularBuffer()

template<typename T >
Chroma::CircularBuffer< T >::~CircularBuffer ( )
inline

Destructor is automatic.

Definition at line 58 of file circular_buffer.h.

◆ CircularBuffer() [2/2]

template<typename T >
Chroma::CircularBuffer< T >::CircularBuffer ( const CircularBuffer< T > &  c)
inline

Copy constructor.

Definition at line 61 of file circular_buffer.h.

Member Function Documentation

◆ get()

template<typename T >
void Chroma::CircularBuffer< T >::get ( const unsigned int  i,
T x 
) const
inline

get the ith most recent item

Definition at line 89 of file circular_buffer.h.

References END_CODE, i, index, q, START_CODE, and x.

◆ isEmpty()

template<typename T >
bool Chroma::CircularBuffer< T >::isEmpty ( void  ) const
inline

Is empty check.

Definition at line 124 of file circular_buffer.h.

◆ operator[]() [1/2]

template<typename T >
T& Chroma::CircularBuffer< T >::operator[] ( int  i)
inline

Definition at line 114 of file circular_buffer.h.

References i, index, and q.

◆ operator[]() [2/2]

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

Definition at line 105 of file circular_buffer.h.

References i, index, and q.

◆ push()

template<typename T >
void Chroma::CircularBuffer< T >::push ( const T e)
inline

push in an item as most recent.

Definition at line 130 of file circular_buffer.h.

References END_CODE, q, and START_CODE.

◆ replaceHead()

template<typename T >
void Chroma::CircularBuffer< T >::replaceHead ( const T x)
inline

Definition at line 207 of file circular_buffer.h.

References q, and x.

◆ reset()

template<typename T >
void Chroma::CircularBuffer< T >::reset ( void  )
inline

Nuke it:

Definition at line 68 of file circular_buffer.h.

◆ size()

template<typename T >
int Chroma::CircularBuffer< T >::size ( void  ) const
inline

◆ sizeMax()

template<typename T >
int Chroma::CircularBuffer< T >::sizeMax ( void  ) const
inline

Get the maximum number of data items one can store.

Definition at line 79 of file circular_buffer.h.

Member Data Documentation

◆ end

template<typename T >
unsigned int Chroma::CircularBuffer< T >::end
private

Definition at line 218 of file circular_buffer.h.

◆ q

template<typename T >
multi1d<T> Chroma::CircularBuffer< T >::q
private

Definition at line 216 of file circular_buffer.h.

◆ size_internal

template<typename T >
unsigned int Chroma::CircularBuffer< T >::size_internal
private

Definition at line 215 of file circular_buffer.h.

◆ size_max

template<typename T >
unsigned int Chroma::CircularBuffer< T >::size_max
private

Definition at line 214 of file circular_buffer.h.

◆ start

template<typename T >
unsigned int Chroma::CircularBuffer< T >::start
private

Definition at line 217 of file circular_buffer.h.


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