PixelLightAPI
.
|
Stack template (FILO -> First In Last Out) More...
#include <Stack.h>
Public Member Functions | |
Stack () | |
Constructor. | |
Stack (const Stack< ValueType > &cSource) | |
Copy constructor. | |
~Stack () | |
Destructor. | |
bool | Push (const ValueType &Element) |
Push an element onto the stack (enqueue) | |
bool | Pop (ValueType *pElement=nullptr) |
Pops the top element from the stack (dequeue) | |
ValueType | Top () const |
Returns the top element without removing it. | |
ValueType | Bottom () const |
Returns the bottom element without removing it. | |
uint32 | GetNumOfElements () const |
Returns the number of elements on the stack. | |
Stack< ValueType > & | operator= (const Stack< ValueType > &cSource) |
Copies the data from another stack. | |
void | Clear () |
Clears the whole stack. | |
virtual Iterator< ValueType > | GetIterator (uint32 nIndex=0) const override |
Returns an iterator operating on the derived data structure. | |
virtual ConstIterator< ValueType > | GetConstIterator (uint32 nIndex=0) const override |
Returns a constant iterator operating on the derived data structure. | |
virtual Iterator< ValueType > | GetEndIterator () const override |
Returns an iterator operating on the derived data structure and starting at the end. | |
virtual ConstIterator< ValueType > | GetConstEndIterator () const override |
Returns a constant iterator operating on the derived data structure and starting at the end. |
Stack template (FILO -> First In Last Out)
* Simple extendable stack using a linked list * The stack will hold copies of the type used in the stack, * so note that your classes should supply a copy (=) operator! * * Usage example: * Stack<MyClass> cStack; // Create stack * MyClass T, T1, T2, T3; // Test class instances * cStack.Push(T1); // Push a copy of T1 onto the stack * cStack.Push(T2); // Push a copy of T2 onto the stack * cStack.Push(T3); // Push a copy of T3 onto the stack * cStack.Pop(&T); // Pop last element (T3) * cStack.Pop(&T); // Pop last element (T2) * cStack.Pop(&T); // Pop last element (T1) *
PLCore::Stack< ValueType >::Stack | ( | ) |
PLCore::Stack< ValueType >::Stack | ( | const Stack< ValueType > & | cSource | ) |
Copy constructor.
[in] | cSource | Source stack to copy from |
PLCore::Stack< ValueType >::~Stack | ( | ) |
Destructor.
bool PLCore::Stack< ValueType >::Push | ( | const ValueType & | Element | ) |
Push an element onto the stack (enqueue)
Push an element onto the stack.
[in] | Element | New stack element |
bool PLCore::Stack< ValueType >::Pop | ( | ValueType * | pElement = nullptr | ) |
Pops the top element from the stack (dequeue)
Pops the top element from the stack.
[out] | pElement | If not a null pointer, this will receive the popped element |
ValueType PLCore::Stack< ValueType >::Top | ( | ) | const |
Returns the top element without removing it.
Get the top element without removing it.
ValueType PLCore::Stack< ValueType >::Bottom | ( | ) | const |
Returns the bottom element without removing it.
Get the bottom element without removing it.
uint32 PLCore::Stack< ValueType >::GetNumOfElements | ( | ) | const |
Returns the number of elements on the stack.
Returns the number of element on the stack.
Stack< ValueType > & PLCore::Stack< ValueType >::operator= | ( | const Stack< ValueType > & | cSource | ) |
Copies the data from another stack.
[in] | cSource | Stack to copy from |
void PLCore::Stack< ValueType >::Clear | ( | ) |
Clears the whole stack.
Iterator< ValueType > PLCore::Stack< ValueType >::GetIterator | ( | uint32 | nIndex = 0 | ) | const [override, virtual] |
Returns an iterator operating on the derived data structure.
[in] | nIndex | Start index, if >= 'total number of elements' the index is set to the last valid index |
Implements PLCore::Iterable< ValueType >.
ConstIterator< ValueType > PLCore::Stack< ValueType >::GetConstIterator | ( | uint32 | nIndex = 0 | ) | const [override, virtual] |
Returns a constant iterator operating on the derived data structure.
[in] | nIndex | Start index, if >= 'total number of elements' the index is set to the last valid index |
Implements PLCore::Iterable< ValueType >.
Iterator< ValueType > PLCore::Stack< ValueType >::GetEndIterator | ( | ) | const [override, virtual] |
Returns an iterator operating on the derived data structure and starting at the end.
Implements PLCore::Iterable< ValueType >.
ConstIterator< ValueType > PLCore::Stack< ValueType >::GetConstEndIterator | ( | ) | const [override, virtual] |
Returns a constant iterator operating on the derived data structure and starting at the end.
Implements PLCore::Iterable< ValueType >.
|