Dune::GenericIterator< C, T, D > Class Template Reference
[GenericIterator]

#include <genericiterator.hh>

Inheritance diagram for Dune::GenericIterator< C, T, D >:

Dune::RandomAccessIteratorFacade< T, V, R, D >

List of all members.


Detailed Description

template<class C, class T, class D = std::ptrdiff_t>
class Dune::GenericIterator< C, T, D >

Generic class for stl conformant iterators for container classes with operator[].

If template parameter C has a const qualifier we are a const iterator, otherwise we are a mutable iterator.


Public Types

typedef C Container
 The type of container we are an iterator for.
typedef T Value
 The value type of the iterator.
typedef D DifferenceType
 The type of the difference between two positions.
typedef T DerivedType
 The type of derived iterator.
typedef V * Pointer
 The pointer to the Value.
typedef R Reference
 The type of the reference to the values accessed.

Public Member Functions

 GenericIterator (Container &cont, DifferenceType pos)
 Constructor.
 GenericIterator (const GenericIterator< typename remove_const< Container >::type, typename remove_const< T >::type, D > &other)
 Copy constructor.
 GenericIterator (const GenericIterator< const typename remove_const< Container >::type, const typename remove_const< T >::type, D > &other)
 Copy constructor.
Reference operator* () const
 Dereferencing operator.
Reference operator[] (DifferenceType n) const
 Get the element n positions from the current one.
DerivedTypeoperator++ ()
 Preincrement operator.
DerivedType operator++ (int)
 Postincrement operator.
DerivedTypeoperator-- ()
 Predecrement operator.
DerivedType operator-- (int)
 Postdecrement operator.

Member Typedef Documentation

template<class C, class T, class D = std::ptrdiff_t>
typedef C Dune::GenericIterator< C, T, D >::Container

The type of container we are an iterator for.

The container type must provide a operator[] method.

If C has a const qualifier we are a const iterator, otherwise we are a mutable iterator.

template<class C, class T, class D = std::ptrdiff_t>
typedef T Dune::GenericIterator< C, T, D >::Value

The value type of the iterator.

This is the return type of the iterator returned when derefencing.

Reimplemented from Dune::RandomAccessIteratorFacade< T, V, R, D >.

template<class T, class V, class R = V&, class D = std::ptrdiff_t>
typedef T Dune::RandomAccessIteratorFacade< T, V, R, D >::DerivedType [inherited]

The type of derived iterator.

The iterator has to define following functions have to be present:

 // Access the value referred to.
 Reference dereference() const;

 // Compare for equality with j
 equals(i);

 // position the iterator at the next element.
 void increment()

 // position the iterator at the previous element.
 void decrement()

 // advance the iterator by a number of positions-
 void advance(DifferenceType n);
 // calculate the distance to another iterator.
 // One should incorporate an assertion wether
 // the same containers are referenced
 DifferenceType distanceTo(j) const;

For an elaborate explanation see the STL Documentation


Constructor & Destructor Documentation

template<class C, class T, class D = std::ptrdiff_t>
Dune::GenericIterator< C, T, D >::GenericIterator ( Container cont,
DifferenceType  pos 
) [inline]

Constructor.

Parameters:
cont Reference to the container we are an iterator for.
pos The postion the Iterator will be positioned to. (e. g. 0 for an iterator return by Container::begin() or the sizeof the container for an iterator returned by Container::end()

template<class C, class T, class D = std::ptrdiff_t>
Dune::GenericIterator< C, T, D >::GenericIterator ( const GenericIterator< typename remove_const< Container >::type, typename remove_const< T >::type, D > &  other  )  [inline]

Copy constructor.

This is somehow hard to understand, therefore play with the cases: 1. if we are mutable this is the only valid copy constructor, as the arguments is a mutable iterator 2. if we are a const iterator the argument is a mutable iterator => This is the needed conversion to initialize a const iterator form a mutable one.

template<class C, class T, class D = std::ptrdiff_t>
Dune::GenericIterator< C, T, D >::GenericIterator ( const GenericIterator< const typename remove_const< Container >::type, const typename remove_const< T >::type, D > &  other  )  [inline]

Copy constructor.

Warning:
Calling this method results in a compiler error, if this is a mutable iterator.
This is somehow hard to understand, therefore play with the cases: 1. if we are mutable the arguments is a const iterator and therefore calling this method is mistake in the users code and results in a (probably not understandable compiler error 2. If we are a const iterator this is the default copy constructor as the argument is a const iterator too.


Member Function Documentation

template<class T, class V, class R = V&, class D = std::ptrdiff_t>
Reference Dune::RandomAccessIteratorFacade< T, V, R, D >::operator[] ( DifferenceType  n  )  const [inline, inherited]

Get the element n positions from the current one.

Parameters:
n The distance to the element.
Returns:
The element at that distance.


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

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].