Dune::GenericIterator< C, T, D > Class Template Reference
[GenericIterator]
#include <genericiterator.hh>
Inheritance diagram for Dune::GenericIterator< C, T, D >:

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 GenericIterator< C, T > | DerivedType |
The type of derived iterator. | |
typedef T * | Pointer |
The pointer to the Value. | |
typedef T & | 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. | |
DerivedType & | operator++ () |
Preincrement operator. | |
DerivedType | operator++ (int) |
Postincrement operator. | |
DerivedType & | operator-- () |
Predecrement operator. | |
DerivedType | operator-- (int) |
Postdecrement operator. |
Member Typedef Documentation
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.
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< GenericIterator< C, T >, T, T &, D >.
typedef GenericIterator< C, T > Dune::RandomAccessIteratorFacade< GenericIterator< C, T > , T , T & , 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
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()
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.
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.
Member Function Documentation
Reference Dune::RandomAccessIteratorFacade< GenericIterator< C, T > , T , T & , 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: