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

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

#include <Stack.h>

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

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


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:14
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported