STIR  6.2.0
Public Types | Public Member Functions | Friends | List of all members
stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr > Class Template Reference

Class FullArrayIterator implements (forward) iterators that go through all elements of an Array. More...

#include "stir/FullArrayIterator.h"

Public Types

typedef std::forward_iterator_tag iterator_category
 
typedef std::ptrdiff_t difference_type
 
typedef elemT value_type
 
typedef _Ref reference
 
typedef _Ptr pointer
 

Public Member Functions

 FullArrayIterator ()
 default constructor
 
 FullArrayIterator (const FullArrayIterator &)
 copy constructor
 
 FullArrayIterator (const topleveliterT &top_level_iter, const topleveliterT &last_top_level_iter, const restiterT &rest_iter, const restiterT &last_rest_iter)
 constructor to initialise the members
 
template<typename othertopleveliterT , typename otherrestiterT , typename _otherRef , typename _otherPtr >
 FullArrayIterator (FullArrayIterator< othertopleveliterT, otherrestiterT, elemT, _otherRef, _otherPtr > const &other, typename boost::enable_if_convertible< othertopleveliterT, topleveliterT >::type *=0, typename boost::enable_if_convertible< otherrestiterT, restiterT >::type *=0)
 some magic trickery to be able to assign iterators to const iterators etc, but not to incompatible types More...
 
 FullArrayIterator (unsigned)
 constructor with 0 (only 0, not another number) More...
 
FullArrayIteratoroperator++ ()
 prefix increment More...
 
FullArrayIterator operator++ (int)
 postfix increment
 
bool operator== (const FullArrayIterator &) const
 comparison operator
 
bool operator!= (const FullArrayIterator &) const
 
reference operator* () const
 dereferencing operator
 
pointer operator-> () const
 member-selection operator
 
template<class topleveliterT, class restiterT, class elemT , class _Ref , class _Ptr >
 FullArrayIterator (const FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr > &iter2)
 

Friends

template<class , class , class , class , class >
class FullArrayIterator
 

Detailed Description

template<typename topleveliterT, typename restiterT, typename elemT, typename _Ref, typename _Ptr>
class stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr >

Class FullArrayIterator implements (forward) iterators that go through all elements of an Array.

Warning
This class should never be used explicitly, but only through the typedefs Array::full_iterator et al.
This class is effectively superseded by NestedIterator, although Array still uses FullArrayIterator.

This implementation assumes that restiterT has begin_all() and end_all() members. Moreover, for the usual for loops to work, there is a requirement on how the class that uses FullArrayIterator implements end_all(). See the implementation of Array::end_all().

Todo:
use std::enable_if and std::is_convertible as opposed to boost::enable_if_convertible

Constructor & Destructor Documentation

◆ FullArrayIterator() [1/2]

template<typename topleveliterT, typename restiterT, typename elemT, typename _Ref, typename _Ptr>
template<typename othertopleveliterT , typename otherrestiterT , typename _otherRef , typename _otherPtr >
stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr >::FullArrayIterator ( FullArrayIterator< othertopleveliterT, otherrestiterT, elemT, _otherRef, _otherPtr > const &  other,
typename boost::enable_if_convertible< othertopleveliterT, topleveliterT >::type *  = 0,
typename boost::enable_if_convertible< otherrestiterT, restiterT >::type *  = 0 
)
inline

some magic trickery to be able to assign iterators to const iterators etc, but not to incompatible types

Ignore the 2nd and 3rd argument. They are there to let the compiler check if the types are convertible (using the SFINAE principle).

◆ FullArrayIterator() [2/2]

template<class topleveliterT, class restiterT, class elemT , class _Ref , class _Ptr >
stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr >::FullArrayIterator ( unsigned  param)
inline

constructor with 0 (only 0, not another number)

This is necessary to be able to set current_rest_iter in the case of an empty range. This should be used by Array::begin_all() and Array::end_all() such that for an empty array, these 2 (full)iterators are guaranteed to be equal.

Ideally, Array::end_all() would just call restiterT(). However, when going down the recursion, you will end up with the '1D' case where restiterT is an ordinary iterator, which in the case of Array<1,elemT> is just an elemT*. Its default constructor does nothing.

All these complications could be avoided by rewriting operator== as indicated in the code there, but at the expense of worse performance.

Member Function Documentation

◆ operator++()

template<class topleveliterT , class restiterT , class elemT , class _Ref , class _Ptr >
FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr > & stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr >::operator++ ( )
inline

prefix increment

We make sure that incrementing the full_iterator ends up in (last_top_level_iter, last_top_level_iter, 0, 0). This has to represent end_all() of this full_iterator.


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