AskSin++
Public Member Functions | List of all members
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 RingStack< TYPE, SIZE >

Implements a stack which hold SIZE elements. New elements will be stored on top. If the number of elements exceeds SIZE old elements will be removed/overwritten.

Definition at line 14 of file RingBuffer.h.

Constructor & Destructor Documentation

◆ RingStack()

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

Construct and initialize the stack

Definition at line 37 of file RingBuffer.h.

Member Function Documentation

◆ clear()

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

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

Definition at line 43 of file RingBuffer.h.

◆ count()

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

Return the actual number of stored elements

Returns
number of elements currently stored

Definition at line 56 of file RingBuffer.h.

◆ operator[]() [1/2]

template<class TYPE , int SIZE>
TYPE& 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 82 of file RingBuffer.h.

◆ operator[]() [2/2]

template<class TYPE , int SIZE>
const TYPE& 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 91 of file RingBuffer.h.

◆ shift() [1/2]

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

Shift the internal structure to the next element

Returns
true if an old elements is overwritten

Definition at line 61 of file RingBuffer.h.

◆ shift() [2/2]

template<class TYPE , int SIZE>
bool 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 72 of file RingBuffer.h.

◆ size()

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

Return the maximal size of elements which can be stored

Returns
maximal number of elements

Definition at line 51 of file RingBuffer.h.