STIR
6.2.0
|
Class NestedIterator implements a (forward) iterator using a pair of 'nested' iterators. More...
#include "stir/NestedIterator.h"
Public Member Functions | |
NestedIterator () | |
default constructor | |
NestedIterator (const topleveliterT &top_level_iter, const topleveliterT &end_top_level_iter) | |
constructor to initialise the members | |
template<typename othertopleveliterT , typename otherGetRestRangeFunctionT > | |
NestedIterator (NestedIterator< othertopleveliterT, otherGetRestRangeFunctionT > other, typename boost::enable_if_convertible< othertopleveliterT, topleveliterT >::type *=0, typename boost::enable_if_convertible< typename otherGetRestRangeFunctionT::rest_iter_type, rest_iter_type >::type *=0) | |
constructor to convert between nested iterators using convertible top and next level iterators More... | |
NestedIterator & | operator++ () |
prefix increment | |
NestedIterator | operator++ (int) |
postfix increment | |
bool | operator== (const NestedIterator &) const |
test equality | |
bool | operator!= (const NestedIterator &) const |
test equality | |
reference | operator* () const |
dereferencing operator | |
pointer | operator-> () const |
member-selection operator | |
Friends | |
template<class , class > | |
class | NestedIterator |
Class NestedIterator implements a (forward) iterator using a pair of 'nested' iterators.
Suppose you have a container where each element is a container, e.g. std::vector<std::list<int> >
. Using NestedIterator, you can iterate through the 'elements of the elements' (i.e. the int's in the above example).
The template argument GetRestRangeFunctionT
should be a function object that, given a top-level iterator, finds the first and last iterators for the sub-sequence. It defaults to just using
Syntax is somewhat awkward for technical reasons (see the source for operator==). You have to give the begin
and end
of the top-level iterators at construction time. (This would be far more natural when using boost::range).
The 2nd template argument would really be better implemented as a template template. However, some compilers still don't support this.
iterator_category
typedef is hard-wired to be std::forward_iterator_tag
. This would be incorrect if topleveliterT
or rest_iter_type
is only an input or output iterator.
|
inline |
constructor to convert between nested iterators using convertible top and next level iterators
Ignore the 2nd and 3rd argument. They are there to let the compiler check if the types are convertible (using the SFINAE principle).