scire
Sadh's C++ Impromptu Routines Ensemble
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
scire::Stack< Type, SzType > Class Template Reference

Linked list implementation of stack. More...

#include <stack.hpp>

Inheritance diagram for scire::Stack< Type, SzType >:
scire::AStack< Type, SzType > scire::AContainer< Type, SzType >

Public Member Functions

 Stack ()
 initialize a Stack object, with top pointing to nullptr More...
 
 ~Stack ()
 finalize a Stack object by deleting all items from it More...
 
bool Push (const Type &element)
 Push a new element at the top of stack. More...
 
bool Pop ()
 Pop (remove/deduce) an element from the top. More...
 
Type Top () const
 Access the top element of stack. More...
 
SzType Size () const
 number of elements contained in More...
 
bool Add (const Type &element)
 add an element More...
 
bool Deduce ()
 deduce one element More...
 
Type Peek () const
 peek into next element contained in More...
 
virtual bool IsEmpty () const
 check if empty More...
 

Detailed Description

template<typename Type, typename SzType = int>
class scire::Stack< Type, SzType >

Linked list implementation of stack.

Stack implemented as linked items. A top pointer points to first item in the stack. Each item points to next item of it and the last item points to nullptr. Items can be added (push) and removed (pop) at top of the stack.

Definition at line 99 of file stack.hpp.

Constructor & Destructor Documentation

template<typename Type , typename SzType >
scire::Stack< Type, SzType >::Stack ( )

initialize a Stack object, with top pointing to nullptr

Definition at line 143 of file stack.hpp.

template<typename Type , typename SzType >
scire::Stack< Type, SzType >::~Stack ( )

finalize a Stack object by deleting all items from it

Definition at line 151 of file stack.hpp.

Member Function Documentation

template<typename Type , typename SzType = int>
bool scire::AStack< Type, SzType >::Add ( const Type &  element)
inlinevirtualinherited

add an element

Parameters
elementelement to be added as new element
Returns
true on success

Implements scire::AContainer< Type, SzType >.

Definition at line 70 of file stack.hpp.

template<typename Type , typename SzType = int>
bool scire::AStack< Type, SzType >::Deduce ( )
inlinevirtualinherited

deduce one element

Returns
true on success

Implements scire::AContainer< Type, SzType >.

Definition at line 76 of file stack.hpp.

template<typename Type , typename SzType = int>
virtual bool scire::AContainer< Type, SzType >::IsEmpty ( ) const
inlinevirtualinherited

check if empty

Returns
true when empty

Definition at line 75 of file container.hpp.

template<typename Type , typename SzType = int>
Type scire::AStack< Type, SzType >::Peek ( ) const
inlinevirtualinherited

peek into next element contained in

Returns
element

Implements scire::AContainer< Type, SzType >.

Definition at line 82 of file stack.hpp.

template<typename Type , typename SzType >
bool scire::Stack< Type, SzType >::Pop ( )
virtual

Pop (remove/deduce) an element from the top.

Returns
true on success

Implements scire::AStack< Type, SzType >.

Definition at line 179 of file stack.hpp.

template<typename Type , typename SzType >
bool scire::Stack< Type, SzType >::Push ( const Type &  element)
virtual

Push a new element at the top of stack.

Parameters
elementelement to push
Returns
true on success

Implements scire::AStack< Type, SzType >.

Definition at line 170 of file stack.hpp.

template<typename Type , typename SzType >
SzType scire::Stack< Type, SzType >::Size ( ) const
virtual

number of elements contained in

Returns
current size

Implements scire::AStack< Type, SzType >.

Definition at line 164 of file stack.hpp.

template<typename Type , typename SzType >
Type scire::Stack< Type, SzType >::Top ( ) const
virtual

Access the top element of stack.

Returns
element at the top of the stack

Implements scire::AStack< Type, SzType >.

Definition at line 193 of file stack.hpp.


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