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

details MultiArrayNavigator< MULTI_ITERATOR, N > Class Template Reference VIGRA

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
}
}

Member Typedef Documentation

typedef MULTI_ITERATOR::multi_difference_type shape_type

The required shape type for the given iterator type.

typedef MULTI_ITERATOR::iterator iterator

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

Constructor & Destructor Documentation

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

void operator++ ( )

Advance to next starting location.

void operator++ ( int  )

Advance to next starting location.

bool hasMore ( ) const

true if there are more elements.

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.11.1 (Fri May 19 2017)