BusBricks: Content_stack< content_class, MaxSize > Class Template Reference
BusBricks  0.1
Customize bus-communication
Loading...
Searching...
No Matches
Content_stack< content_class, MaxSize > Class Template Reference

Content-Stack-Template the content-stack stores the added items (call-by-value / copy) on internal array the item added last is stacked on top (highest index), the one added first is stored on index "0". More...

#include <Content_stack.h>

Public Member Functions

 Content_stack ()
 Construct Content_stack with zero elements.
 
 ~Content_stack ()
 Destroy the Content_stack object.
 
bool addElement (content_class element)
 Add item to stack.
 
bool deleteElement (int index=0)
 Delete item on index-position from stack and shift all items with higher index, accepts only positive index-positions.
 
content_class * getElement (int index=0)
 Get Pointer to element in the stack. Accepts positive and negative indexing.
 
bool empty ()
 Check if the Stack is empty (size is 0)
 
bool full ()
 Check if the Stack is full (size reached MaxSize)
 

Detailed Description

template<typename content_class, int MaxSize>
class Content_stack< content_class, MaxSize >

Content-Stack-Template the content-stack stores the added items (call-by-value / copy) on internal array the item added last is stacked on top (highest index), the one added first is stored on index "0".

Author
Felix Schuelke (flxsc.nosp@m.ode@.nosp@m.gmail.nosp@m..com)
Template Parameters
content_classtype of the items stored in the stack
MaxSizemaximum number of items to be stored in the stack

Member Function Documentation

◆ addElement()

template<typename content_class , int MaxSize>
bool Content_stack< content_class, MaxSize >::addElement ( content_class element)
inline

Add item to stack.

Parameters
elementItem to add to the stack
Returns
true item added successfully
false item not added, stacksize has reached maximum
Here is the caller graph for this function:

◆ deleteElement()

template<typename content_class , int MaxSize>
bool Content_stack< content_class, MaxSize >::deleteElement ( int index = 0)
inline

Delete item on index-position from stack and shift all items with higher index, accepts only positive index-positions.

Parameters
indexindex of item, that should be deleted (default 0, item on bottom of stack)
Returns
true deleted successfully
false index of element to delete is out of range
Here is the caller graph for this function:

◆ empty()

template<typename content_class , int MaxSize>
bool Content_stack< content_class, MaxSize >::empty ( )
inline

Check if the Stack is empty (size is 0)

Returns
true Stack is empty
false Stack is not empty
Here is the caller graph for this function:

◆ full()

template<typename content_class , int MaxSize>
bool Content_stack< content_class, MaxSize >::full ( )
inline

Check if the Stack is full (size reached MaxSize)

Returns
true Stack is full
false Stack is not full
Here is the caller graph for this function:

◆ getElement()

template<typename content_class , int MaxSize>
content_class * Content_stack< content_class, MaxSize >::getElement ( int index = 0)
inline

Get Pointer to element in the stack. Accepts positive and negative indexing.

Parameters
indexneg. index: return element indexed from end of stack (size) / pos. index: return element indexed from beginning of stack (0)
Returns
content_class* pointer to the indexed item, nullptr if no item is stored at the given index
Here is the caller graph for this function:

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