Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lrt::Iterator Class Template Reference

A bi-directional iterator for collections in libRT. More...

#include <rtiterator.h>

List of all members.

Public Methods

 Iterator (const Iterator< T > &iter)
 Creates a duplicate of the given iterator.

 Iterator (IIteratorImpl< T > *impl)
 Creates an iterator, using the iterator implementation impl.

IIteratorImpl< T > * getImpl ()
 Returns the iterator implementation this iterator is using.

 ~Iterator ()
 Deletes the iterator implementation this iterator is using.

Iterator< T > operator++ (int)
 Proceeds to the next element of the collection.

Iterator< T > operator-- (int)
 Moves to the previous element of the collection.

bool operator== (const Iterator< T > &it) const
 Checks if this iterator and it are at the same position of the same collection object.

Iterator< T > & operator= (const Iterator< T > &it)
 Moves to the position at which it stands.

T & operator * ()
 Returns the element at the current position, or an invalid reference if there isn't any. More...

const T & operator * () const
 Returns the element at the current position, or an invalid reference if there isn't any. More...

Iterator< T > & operator++ ()
 Proceeds to the next element of the collection.

Iterator< T > & operator-- ()
 Moves to the previous element of the collection.

bool hasElement () const
 Checks if there is an element at the current position of this iterator.

bool hasNext () const
 Checks if there is an element at the next position of this iterator.

bool hasPrev () const
 Checks if there is an element at the previous position of this iterator.

T & next ()
 Returns the element at the current position, and moves forward thereafter. More...

T & prev ()
 Returns the element at the current position, and moves to the previous element thereafter. More...

T & get ()
 Returns the element at the current position, or an invalid reference if there isn't any. More...

const T & get () const
 Returns the element at the current position, or an invalid reference if there isn't any. More...

bool canModify () const
 Returns true if the iterator can modify its collection. More...

void remove ()
 Removes the element at the current position, and advances to the next element. More...

Iterator< T > getNext () const
 Returns a new iterator pointing to the next element of the collection.

Iterator< T > getPrev () const
 Returns a new iterator pointing to the previous element of the collection.


Protected Methods

Iterator< T > clone () const
 Clones this iterator by cloning its implementation.


Detailed Description

template<class T>
class lrt::Iterator< T >

A bi-directional iterator for collections in libRT.

This class is just a wrapper class for higher comfort for any iterator implementations. Collections which provide access using iterators, should implement the IIteratorImpl interface in a YourCollection::Iterator class and then return Iterator<T>(new YourCollection::Iterator()) in any access methods (where T is the element type of YourCollection).


Member Function Documentation

template<class T>
bool lrt::Iterator< T >::canModify (    )  const [inline]
 

Returns true if the iterator can modify its collection.

(e.g. remove elements from it.)

template<class T>
const T& lrt::Iterator< T >::get (    )  const [inline]
 

Returns the element at the current position, or an invalid reference if there isn't any.

You should use hasElement() to check the current position before using get().

template<class T>
T& lrt::Iterator< T >::get (    )  [inline]
 

Returns the element at the current position, or an invalid reference if there isn't any.

You should use hasElement() to check the current position before using get().

template<class T>
T& lrt::Iterator< T >::next (    )  [inline]
 

Returns the element at the current position, and moves forward thereafter.

You should use hasElement() to check the current position before using next().

template<class T>
const T& lrt::Iterator< T >::operator * (    )  const [inline]
 

Returns the element at the current position, or an invalid reference if there isn't any.

You should use hasElement() to check the current position before dereferencing the iterator.

template<class T>
T& lrt::Iterator< T >::operator * (    )  [inline]
 

Returns the element at the current position, or an invalid reference if there isn't any.

You should use hasElement() to check the current position before dereferencing the iterator.

template<class T>
T& lrt::Iterator< T >::prev (    )  [inline]
 

Returns the element at the current position, and moves to the previous element thereafter.

You should use hasElement() to check the current position before using prev().

template<class T>
void lrt::Iterator< T >::remove (    )  [inline]
 

Removes the element at the current position, and advances to the next element.

If the iterator cannot be modified, does nothing.

See also:
canModify()


The documentation for this class was generated from the following file:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer