STIRA  0.1
Public Member Functions | Protected Attributes | List of all members
stira::common::FixedBuffer< T > Class Template Reference

A class to represent a buffer of fixed size. More...

#include <FixedBuffer.h>

Public Member Functions

 FixedBuffer (int maxSize, SideOverflow mySide=DELETE_FROM_BEGIN)
 constructor More...
 
 ~FixedBuffer ()
 destructor
 
void AddElement (T newElement)
 Adds a new element to the buffer end Oldest added element is still at mvVector.begin() If the size of the after adding the new element exceeds the maximum length, the oldest element is removed. More...
 
void InsertElementFromStart (T newElement, int positionFromStart=0)
 Inserts a new element to the buffer If the size of the after adding the new element exceeds the maximum length, the oldest element is removed. More...
 
void InsertElementFromEnd (T newElement, int positionFromEnd=0)
 
GetElementFromStart (int index)
 Gets element from end. More...
 
GetElementFromEnd (int index)
 Gets element from end. More...
 
int GetSize ()
 Gets the size of the buffer.
 
void Clear ()
 empties all elements from the buffer
 

Protected Attributes

unsigned int mMaxSize
 maximum size of the buffer
 
SideOverflow mSide
 side of buffer from which to remove the elements when buffer is too large
 
std::vector< T > mvVector
 an STL vector containing the elements
 

Detailed Description

template<class T>
class stira::common::FixedBuffer< T >

A class to represent a buffer of fixed size.

Constructor & Destructor Documentation

template<class T >
stira::common::FixedBuffer< T >::FixedBuffer ( int  maxSize,
SideOverflow  mySide = DELETE_FROM_BEGIN 
)

constructor

Parameters
maxSizemaximum size of the buffer

Member Function Documentation

template<class T >
void stira::common::FixedBuffer< T >::AddElement ( newElement)

Adds a new element to the buffer end Oldest added element is still at mvVector.begin() If the size of the after adding the new element exceeds the maximum length, the oldest element is removed.

Parameters
newElementnew element to add to the buffer
template<class T >
T stira::common::FixedBuffer< T >::GetElementFromEnd ( int  index)

Gets element from end.

Parameters
indexindex of element to retrieve: for last element, index is 0; for one but last, index = 1; for second but last, index = 2 and so on
template<class T >
T stira::common::FixedBuffer< T >::GetElementFromStart ( int  index)

Gets element from end.

Parameters
indexindex of element to retrieve: for last element, index is 0; for one but last, index = 1; for second but last, index = 2 and so on
template<class T >
void stira::common::FixedBuffer< T >::InsertElementFromStart ( newElement,
int  positionFromStart = 0 
)

Inserts a new element to the buffer If the size of the after adding the new element exceeds the maximum length, the oldest element is removed.

Parameters
newElementnew element to add to the buffer

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