[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
General iterators for arrays of arbitrary dimension.
The Multidimensional Iterator concept allows navigation on arrays of arbitrary dimension. It provides two modes of iteration: direct traveral, and hierarchical traversal. In general, hierarchical traversal will be faster, while only direct traversal allows for true random access in all dimensions. Via the dim<K>()
function, operations applying to a particular dimension can be used in the direct traversal mode. In contrast, direct traversal functions should not be used in the hierarchical mode because the hierarchical functions are only well-defined if the iterator points to element 0 in all dimensions below its current dimension. The current dimension of a MultiIterator<N, ...>
is N-1
.
Local Types | Meaning | |
---|---|---|
the underlying arrays's pixel type | ||
the iterator's reference type (return type of | ||
the iterator's pointer type (return type of | ||
the iterator tag ( | ||
Operation | Result | Semantics |
default constructor | ||
| copy constructor | |
| assignment | |
|
| equality (iterators point to the same element) |
|
| inequality (iterators don't point to the same element) |
| access the current element | |
| depends on operation | call member function of underlying pixel type via |
Local Types | Meaning | |
---|---|---|
the iterator's multi-dimensional difference type ( | ||
Operation | Result | Semantics |
| add offset to current position | |
| subtract offset from current position | |
| create traverser by adding offset | |
| create traverser by subtracting offset | |
| access element at offset | |
|
| Access the traverser with the current dimension set to K. Typically used to call navigation functions referring to a particular dimension. i.dim<0>()++; // increment dimension 0 i.dim<1>()++; // increment dimension 1 i.dim<2>()++; // increment dimension 2 j += MultiIterator::multi_difference_type(1,1,1); // same effect |
|
Note that it is impossible to support an operator-
between two iterators which returns a MultiIterator::multi_difference_type
because it is impossible to decide to which dimension a difference applies. Consider for example, a 2-dimensional iterator i
, and let j = i + multi_difference_type(width, 0)
, k = i + multi_difference_type(0,1)
, where width
is the array's total width. In general, j
and k
point to the same memory location, so that the two cases cannot easily be distinguished (it is possible, but iterator performance will suffer significantly, as is experienced with vigra::ImageIterator where differencing is allowed).
Local Types | Meaning | |
---|---|---|
the iterator's difference type ( | ||
type of the next iterator (referring to the next lower dimension) in the hierarchy | ||
Operation | Result | Semantics |
| pre-increment iterator in its current dimension | |
| post-increment iterator in its current dimension | |
| pre-decrement iterator in its current dimension | |
| post-decrement iterator in its current dimension | |
| add | |
| subtract | |
| create new iterator by adding | |
| create new iterator by subtracting | |
|
| difference of |
|
|
|
| access element by adding offset | |
|
| create the hierarchical iterator poiting to the first element in the next lower dimension. MultiIterator<3, int> i3 = ..., end3 = ...; for(; i3 != end3; ++i3) { MultiIterator<3, int>::next_type i2 = i3.begin(), end2 = i3.end(); for(; i2 != end2; ++i2) { MultiIterator<3, int>::next_type::next_type i1 = i2.begin(), end1 = i2.end(); for(; i1 != end1; ++i1) { ... // do something with the current element } } } |
|
| create the hierarchical iterator poiting to the past-the-end location in the next lower dimension. |
|
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|