STIR
6.2.0
|
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... | |
FullArrayIterator & | operator++ () |
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 |
Class FullArrayIterator implements (forward) iterators that go through all elements of an Array.
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().
|
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).
|
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.
|
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.