DUNE: Uniform Navigational Environment  2016.05.0
DUNE::Utils::CircularBuffer< T > Class Template Reference

Detailed Description

template<typename T>
class DUNE::Utils::CircularBuffer< T >

Circular buffer with a maximum fixed-size capacity.

Additions beyond the buffer capacity will result in eviction of the oldest datum.

Classes

class  Error
 

Public Member Functions

 CircularBuffer (uint32_t capacity=1)
 
 CircularBuffer (const CircularBuffer< T > &other)
 
 ~CircularBuffer (void)
 
void clear (void)
 
void setCapacity (uint32_t n)
 
void add (const T &data)
 
T & operator() (uint32_t index)
 
const T & operator() (uint32_t index) const
 
uint32_t getCapacity (void) const
 
uint32_t getSize (void) const
 

Constructor & Destructor Documentation

template<typename T>
DUNE::Utils::CircularBuffer< T >::CircularBuffer ( uint32_t  capacity = 1)
inline

Constructor.

Parameters
capacitymaximum capacity
template<typename T>
DUNE::Utils::CircularBuffer< T >::CircularBuffer ( const CircularBuffer< T > &  other)
inline
Parameters
otherinstance of CircularBuffer<T> to copy.
template<typename T>
DUNE::Utils::CircularBuffer< T >::~CircularBuffer ( void  )
inline

Destructor.

Member Function Documentation

template<typename T>
void DUNE::Utils::CircularBuffer< T >::add ( const T &  data)
inline

Add data to the buffer.

If the buffer is using all its capacity, the oldest data will be overwritten.

Parameters
datadata to add.
template<typename T>
void DUNE::Utils::CircularBuffer< T >::clear ( void  )
inline

Clear the buffer.

template<typename T>
uint32_t DUNE::Utils::CircularBuffer< T >::getCapacity ( void  ) const
inline

Get buffer capacity.

Returns
buffer capacity.
template<typename T>
uint32_t DUNE::Utils::CircularBuffer< T >::getSize ( void  ) const
inline

Get size of the buffer in use.

Returns
buffer size in use.
template<typename T>
T& DUNE::Utils::CircularBuffer< T >::operator() ( uint32_t  index)
inline

Access buffer position.

Parameters
indexposition.
Returns
data at index-th position.
template<typename T>
const T& DUNE::Utils::CircularBuffer< T >::operator() ( uint32_t  index) const
inline

Access buffer position.

Parameters
indexposition.
Returns
data at index-th position.
template<typename T>
void DUNE::Utils::CircularBuffer< T >::setCapacity ( uint32_t  n)
inline

Reset the buffer capacity.

Previous contents are saved in FIFO order up to the new capacity.

Parameters
nnew capacity
Collaboration diagram for DUNE::Utils::CircularBuffer< T >:
Collaboration graph