STIRA
0.1
|
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) |
T | GetElementFromStart (int index) |
Gets element from end. More... | |
T | 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 | |
A class to represent a buffer of fixed size.
stira::common::FixedBuffer< T >::FixedBuffer | ( | int | maxSize, |
SideOverflow | mySide = DELETE_FROM_BEGIN |
||
) |
constructor
maxSize | maximum size of the buffer |
void stira::common::FixedBuffer< T >::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.
newElement | new element to add to the buffer |
T stira::common::FixedBuffer< T >::GetElementFromEnd | ( | int | index | ) |
Gets element from end.
index | index 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 |
T stira::common::FixedBuffer< T >::GetElementFromStart | ( | int | index | ) |
Gets element from end.
index | index 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 |
void stira::common::FixedBuffer< T >::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.
newElement | new element to add to the buffer |