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

Iterator class. More...

#include <Iterator.h>

List of all members.

Public Member Functions

 Iterator (IteratorImpl< ValueType > &cIteratorImpl)
 Constructor.
 Iterator (const Iterator< ValueType > &cIterator)
 Copy constructor.
 ~Iterator ()
 Destructor.
Iterator< ValueType > & operator= (const Iterator< ValueType > &cIterator)
 Copy operator.
bool HasNext () const
 Checks whether the iterator can return a next element.
ValueType & Next ()
 Returns the next element.
ValueType & operator++ ()
 Returns the next element.
bool HasPrevious () const
 Checks whether the iterator can return a previous element.
ValueType & Previous ()
 Returns the previous element.
ValueType & operator-- ()
 Returns the previous element.

Detailed Description

template<class ValueType>
class PLCore::Iterator< ValueType >

Iterator class.

Remarks:
If an iterator is used, the iterable (for instance 'Map', 'Container' or 'Heap') the iterator is operating on should not be manipulated by adding/removing new elements because this may produce undefined behavior! Is highly recommended to keep the iterator in the smallest possible local scope and to never keep an iterator as for instance pointer over a long time.
*    Usage example:
*    Array<String> lstNames;	// Iterable container
*    lstNames.Add("Lenny");		// Add "Lenny" to the iterable container
*    lstNames.Add("Barny");		// Add "Barny" to the iterable container
*    lstNames.Add("Homer");		// Add "Homer" to the iterable container
*    Iterator<String> cIterator = lstNames.GetIterator();	// Get an iterator instance
*    while (cIterator.HasNext())	// Is there a next element?
*        String sName = cIterator.Next();	// Return the next element, in this case, returns "Lenny", then "Barny" and then "Homer"
*  
Note:
  • As the class same indicates, this is an implementation of the iterator design pattern
  • An iterator is similar to a "for each loop"

Constructor & Destructor Documentation

template<class ValueType>
PLCore::Iterator< ValueType >::Iterator ( IteratorImpl< ValueType > &  cIteratorImpl)

Constructor.

Parameters:
[in]cIteratorImplReference to the iterator specific implementation
template<class ValueType>
PLCore::Iterator< ValueType >::Iterator ( const Iterator< ValueType > &  cIterator)

Copy constructor.

Parameters:
[in]cIteratorSource to copy from
template<class ValueType >
PLCore::Iterator< ValueType >::~Iterator ( )

Destructor.


Member Function Documentation

template<class ValueType>
Iterator< ValueType > & PLCore::Iterator< ValueType >::operator= ( const Iterator< ValueType > &  cIterator)

Copy operator.

Parameters:
[in]cIteratorSource to copy from
Returns:
Reference to this instance
template<class ValueType >
bool PLCore::Iterator< ValueType >::HasNext ( ) const

Checks whether the iterator can return a next element.

Returns:
'true' if the iterator can return a next element, else 'false'
template<class ValueType >
ValueType & PLCore::Iterator< ValueType >::Next ( )

Returns the next element.

Returns:
Reference to the next element, reference to the 'Null'-object on error
template<class ValueType >
ValueType & PLCore::Iterator< ValueType >::operator++ ( )

Returns the next element.

Returns:
Reference to the next element, reference to the 'Null'-object on error
template<class ValueType >
bool PLCore::Iterator< ValueType >::HasPrevious ( ) const

Checks whether the iterator can return a previous element.

Returns:
'true' if the iterator can return a previous element, else 'false'
template<class ValueType >
ValueType & PLCore::Iterator< ValueType >::Previous ( )

Returns the previous element.

Returns:
Reference to the previous element, reference to the 'Null'-object on error
template<class ValueType >
ValueType & PLCore::Iterator< ValueType >::operator-- ( )

Returns the previous element.

Returns:
Reference to the previous element, reference to the 'Null'-object on error

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