[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

MultiArrayNavigator< MULTI_ITERATOR, N > Class Template Reference

A navigator that provides access to the 1D subranges of an n-dimensional range given by a vigra::MultiIterator and an nD shape. More...

#include <vigra/navigator.hxx>

Public Types

typedef MULTI_ITERATOR::iterator iterator
 
typedef MULTI_ITERATOR::multi_difference_type shape_type
 

Public Member Functions

bool atEnd () const
 
bool hasMore () const
 
 MultiArrayNavigator (MULTI_ITERATOR const &i, shape_type const &shape, unsigned int inner_dimension)
 
void operator++ ()
 
void operator++ (int)
 

Detailed Description

template<class MULTI_ITERATOR, unsigned int N>
class vigra::MultiArrayNavigator< MULTI_ITERATOR, N >

A navigator that provides access to the 1D subranges of an n-dimensional range given by a vigra::MultiIterator and an nD shape.

Normally, the innermost loop of an iteration extends over the innermost dimension of a given array. Sometimes, however, it is necessary to have some other dimension in the inner loop. For example, instead of iterating over the rows, the inner loop should extend over the columns. The class MultiArrayNavigator encapsulates the necessary functionality. Given an arbitrary dimensional array (represented by a vigra::MultiIterator/shape pair), and the desired inner loop dimension d, it moves the encapsulated iterator to all possible starting points of 1D subsets along the given dimension (e.g. all columns). By calling begin() and end(), one can then obtain an STL-compatible 1-dimensional iterator for the current subset.

The template parameters specify the embedded iterator type and its dimension.

Usage:

#include <vigra/navigator.hxx>

Namespace: vigra

Array a(Array::size_type(X, Y, Z));
for(int d=0; d<3; ++d)
{
// create Navigator for dimension d
Navigator nav(a.traverser_begin(), a.shape(), d);
// outer loop: move navigator to all starting points
// of 1D subsets that run parallel to coordinate axis d
for(; nav.hasMore(); ++nav)
{
// inner loop: linear iteration over current subset
// d == {0, 1, 2}: iterate along {x, y, z}-axis respectively
Navigator::iterator i = nav.begin(), end = nav.end();
for(; i != end; ++i)
// do something
}
}
A navigator that provides access to the 1D subranges of an n-dimensional range given by a vigra::Mult...
Definition navigator.hxx:101
Main MultiArray class containing the memory management.
Definition multi_fwd.hxx:131

Member Typedef Documentation

◆ shape_type

template<class MULTI_ITERATOR , unsigned int N>
MULTI_ITERATOR::multi_difference_type shape_type

The required shape type for the given iterator type.

◆ iterator

template<class MULTI_ITERATOR , unsigned int N>
MULTI_ITERATOR::iterator iterator

The iterator type for the inner loop (result of begin() and end()).

Constructor & Destructor Documentation

◆ MultiArrayNavigator()

template<class MULTI_ITERATOR , unsigned int N>
MultiArrayNavigator ( MULTI_ITERATOR const & i,
shape_type const & shape,
unsigned int inner_dimension )

Construct navigator for multi-dimensional iterator i, array shape shape and inner loop dimension inner_dimension.

Member Function Documentation

◆ operator++() [1/2]

template<class MULTI_ITERATOR , unsigned int N>
void operator++ ( )

Advance to next starting location.

◆ operator++() [2/2]

template<class MULTI_ITERATOR , unsigned int N>
void operator++ ( int )

Advance to next starting location.

◆ hasMore()

template<class MULTI_ITERATOR , unsigned int N>
bool hasMore ( ) const

true if there are more elements.

◆ atEnd()

template<class MULTI_ITERATOR , unsigned int N>
bool atEnd ( ) const

true if iterator is exhausted.


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

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.12.2