AskSin++
Public Member Functions | List of all members
as::RingStack< TYPE, SIZE > Class Template Reference

#include <RingBuffer.h>

Public Member Functions

 RingStack ()
 
void clear ()
 
int size () const
 
int count () const
 
bool shift ()
 
bool shift (const TYPE &data)
 
TYPE & operator[] (int index)
 
const TYPE & operator[] (int index) const
 

Detailed Description

template<class TYPE, int SIZE>
class as::RingStack< TYPE, SIZE >

Implements a stack with SIZE elements. New elements will be stored on top. If the number of elements exceeds SIZE the oldest element will be removed/overwritten.

Definition at line 15 of file RingBuffer.h.

Constructor & Destructor Documentation

◆ RingStack()

template<class TYPE , int SIZE>
as::RingStack< TYPE, SIZE >::RingStack ( )
inline

Construct and initialize the stack

Definition at line 38 of file RingBuffer.h.

Member Function Documentation

◆ clear()

template<class TYPE , int SIZE>
void as::RingStack< TYPE, SIZE >::clear ( )
inline

Clear the stack. After this call the stack is empty.

Definition at line 44 of file RingBuffer.h.

◆ count()

template<class TYPE , int SIZE>
int as::RingStack< TYPE, SIZE >::count ( ) const
inline

Return the actual number of stored elements

Returns
number of elements currently stored

Definition at line 57 of file RingBuffer.h.

◆ operator[]() [1/2]

template<class TYPE , int SIZE>
TYPE& as::RingStack< TYPE, SIZE >::operator[] ( int  index)
inline

Array-operator to access an element on the stack

Parameters
indexthe index of the element on the stack to return
Returns
reference to the element on the stack

Definition at line 83 of file RingBuffer.h.

◆ operator[]() [2/2]

template<class TYPE , int SIZE>
const TYPE& as::RingStack< TYPE, SIZE >::operator[] ( int  index) const
inline

Array-operator to access an element on the stack

Parameters
indexthe index of the element on the stack to return
Returns
reference to the element on the stack

Definition at line 92 of file RingBuffer.h.

◆ shift() [1/2]

template<class TYPE , int SIZE>
bool as::RingStack< TYPE, SIZE >::shift ( )
inline

Shift the internal structure to the next element

Returns
true if an old elements is overwritten

Definition at line 62 of file RingBuffer.h.

◆ shift() [2/2]

template<class TYPE , int SIZE>
bool as::RingStack< TYPE, SIZE >::shift ( const TYPE &  data)
inline

Shift the stack to the next element and store the given value on the top

Parameters
datavalue to store
Returns
true if an old elements is overwritten

Definition at line 73 of file RingBuffer.h.

◆ size()

template<class TYPE , int SIZE>
int as::RingStack< TYPE, SIZE >::size ( ) const
inline

Return the maximal size of elements which can be stored

Returns
maximal number of elements

Definition at line 52 of file RingBuffer.h.