PixelLightAPI  .
Public Member Functions
PLCore::Stack< ValueType > Class Template Reference

Stack template (FILO -> First In Last Out) More...

#include <Stack.h>

Inheritance diagram for PLCore::Stack< ValueType >:
Inheritance graph
[legend]

List of all members.

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.

Detailed Description

template<class ValueType>
class PLCore::Stack< ValueType >

Stack template (FILO -> First In Last Out)

Remarks:
*    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)
*  

Constructor & Destructor Documentation

template<class ValueType >
PLCore::Stack< ValueType >::Stack ( )
template<class ValueType>
PLCore::Stack< ValueType >::Stack ( const Stack< ValueType > &  cSource)

Copy constructor.

Parameters:
[in]cSourceSource stack to copy from
template<class ValueType >
PLCore::Stack< ValueType >::~Stack ( )

Destructor.


Member Function Documentation

template<class ValueType>
bool PLCore::Stack< ValueType >::Push ( const ValueType &  Element)

Push an element onto the stack (enqueue)

Push an element onto the stack.

Parameters:
[in]ElementNew stack element
Returns:
'true' if all went fine, else 'false'
template<class ValueType>
bool PLCore::Stack< ValueType >::Pop ( ValueType *  pElement = nullptr)

Pops the top element from the stack (dequeue)

Pops the top element from the stack.

Parameters:
[out]pElementIf not a null pointer, this will receive the popped element
Returns:
'true' if all went fine, else 'false'
Note:
  • On error, pElement is NOT touched, so ensure that you take this case into account!
template<class ValueType >
ValueType PLCore::Stack< ValueType >::Top ( ) const

Returns the top element without removing it.

Get the top element without removing it.

Returns:
Top stack element (newest element)
template<class ValueType >
ValueType PLCore::Stack< ValueType >::Bottom ( ) const

Returns the bottom element without removing it.

Get the bottom element without removing it.

Returns:
Bottom stack element (oldest element)
template<class ValueType >
uint32 PLCore::Stack< ValueType >::GetNumOfElements ( ) const

Returns the number of elements on the stack.

Returns the number of element on the stack.

Returns:
Number of stack elements
template<class ValueType>
Stack< ValueType > & PLCore::Stack< ValueType >::operator= ( const Stack< ValueType > &  cSource)

Copies the data from another stack.

Parameters:
[in]cSourceStack to copy from
Returns:
Reference to this instance
template<class ValueType >
void PLCore::Stack< ValueType >::Clear ( )

Clears the whole stack.

template<class ValueType >
Iterator< ValueType > PLCore::Stack< ValueType >::GetIterator ( uint32  nIndex = 0) const [override, virtual]

Returns an iterator operating on the derived data structure.

Parameters:
[in]nIndexStart index, if >= 'total number of elements' the index is set to the last valid index
Returns:
Iterator operating on the derived

Implements PLCore::Iterable< ValueType >.

template<class ValueType >
ConstIterator< ValueType > PLCore::Stack< ValueType >::GetConstIterator ( uint32  nIndex = 0) const [override, virtual]

Returns a constant iterator operating on the derived data structure.

Parameters:
[in]nIndexStart index, if >= 'total number of elements' the index is set to the last valid index
Returns:
Constant iterator operating on the derived

Implements PLCore::Iterable< ValueType >.

template<class ValueType >
Iterator< ValueType > PLCore::Stack< ValueType >::GetEndIterator ( ) const [override, virtual]

Returns an iterator operating on the derived data structure and starting at the end.

Returns:
Iterator operating on the derived,
Remarks:
Use this function to get an iterator if you want to iterate in reversed order starting at the end last element.

Implements PLCore::Iterable< ValueType >.

template<class 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.

Returns:
Constant iterator operating on the derived,
Remarks:
Use this function to get a constant iterator if you want to iterate in reversed order starting at the end last element.

Implements PLCore::Iterable< ValueType >.


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:25
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported