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

Queue (FIFO -> First In First Out) template. More...

#include <Queue.h>

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

List of all members.

Public Member Functions

 Queue ()
 Constructor.
 Queue (const Queue< ValueType > &cSource)
 Copy constructor.
 ~Queue ()
 Destructor.
bool Push (const ValueType &Element)
 Push an element onto the queue (enqueue)
bool Pop (ValueType *pElement=nullptr)
 Pops the bottom element from the queue (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 queue.
Queue< ValueType > & operator= (const Queue< ValueType > &cSource)
 Copies the data from another queue.
void Clear ()
 Clears the whole queue.
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::Queue< ValueType >

Queue (FIFO -> First In First Out) template.

Remarks:
*    Simple extendable queue using a linked list.
*    The queue will hold copies of the type used in the queue,
*    so note that your classes should supply a copy (=) operator!
*
*    Usage example:
*    Queue<MyClass> cQueue;  // Create queue
*    MyClass T, T1, T2, T3;  // Test class instances
*    cQueue.Push(T1);        // Push a copy of T1 onto the queue
*    cQueue.Push(T2);        // Push a copy of T2 onto the queue
*    cQueue.Push(T3);        // Push a copy of T3 onto the queue
*    cQueue.Pop(&T);         // Pop last element (T1)
*    cQueue.Pop(&T);         // Pop last element (T2)
*    cQueue.Pop(&T);         // Pop last element (T3)
*  

Constructor & Destructor Documentation

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

Copy constructor.

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

Destructor.


Member Function Documentation

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

Push an element onto the queue (enqueue)

Push an element onto the queue.

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

Pops the bottom element from the queue (dequeue)

Pops the bottom element from the queue.

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::Queue< ValueType >::Top ( ) const

Returns the top element without removing it.

Get the top element without removing it.

Returns:
Top queue element (newest element)
template<class ValueType >
ValueType PLCore::Queue< ValueType >::Bottom ( ) const

Returns the bottom element without removing it.

Get the bottom element without removing it.

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

Returns the number of elements on the queue.

Returns the number of element on the queue.

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

Copies the data from another queue.

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

Clears the whole queue.

template<class ValueType >
Iterator< ValueType > PLCore::Queue< 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::Queue< 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::Queue< 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::Queue< 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