#include <ArrayPosIter.h>
Inheritance diagram for casa::ArrayPositionIterator:


ArrayPositionIterator manipulates an IPosition "cursor" through some volume defined by an origin and shape. This position can in turn be used to index into, or otherwise define a position in, an Array. Normally users won't use this class directly, rather they will use an ArrayIterator, VectorIterator or MatrixIterator object, which in turn uses this class. ArrayPositionIterator is also used in the implementation of Array.
template<class T> void verySlowArrayCopy(Array<T> &to, const Array<T> &from) { if (! to.conform(from)) { // throw some error } ArrayPositionIterator toiter(to.shape(), to.origin(),0); ArrayPositionIterator fromiter(from.shape(), from.origin(),0); // If to.origin() == from.origin() we only need one iterator // or we could offset positions by the difference in origins. // The "0" means we are stepping by scalars. while (! toiter.pastEnd()) { // we know arrays conform to(toiter.pos()) = fromiter(fromiter.pos()); toiter.next(); fromiter.next(); } }
Iteration can be done by any combination of axes, but it can only be done for full axes.
The iteration step always "fills up" its dimensionality. E.g., if we are stepping through a cube by matrices, the matrix completely fills up the plane. Class ArrayLattice in the lattices package can be used to iterate with partial volumes.
Tip: All the array iterator classes should probably be reimplemented; their implementation is a bit ugly.
Definition at line 80 of file ArrayPosIter.h.
Public Member Functions | |
| ArrayPositionIterator (const IPosition &shape, const IPosition &axes, Bool axesAreCursor=True) | |
| Step through an array using the given axes. | |
| virtual | ~ArrayPositionIterator () |
| Bool | atStart () const |
| Returns true of the cursor is at the origin. | |
| Bool | pastEnd () const |
| We are at the "end" if we cannot advance any more. | |
| const IPosition & | pos () const |
| Return the position of the cursor. | |
| IPosition | endPos () const |
| Return the end position of the cursor. | |
| virtual void | next () |
| Advance the cursor to its next position. | |
| uInt | ndim () const |
| Dimensionality of the array we are iterating through. | |
| const IPosition & | iterAxes () const |
| Return the iteration axes. | |
| const IPosition & | cursorAxes () const |
| Return the cursor axes. | |
| virtual void | reset () |
| Reset the cursor to the beginning of the volume. | |
| void | origin () |
Protected Member Functions | |
| uInt | nextStep () |
| Advance cursor to its next position and tell which dimension stepped. | |
| uInt | dimIter () const |
| What is the dimensionality of the "step" the cursor takes, i.e. | |
Private Member Functions | |
| void | setup (uInt byDim) |
| Setup the object for the constructor. | |
| void | setup (const IPosition &axes, Bool axesAreCursor) |
Private Attributes | |
| IPosition | Start |
| IPosition | Shape |
| IPosition | End |
| IPosition | Cursor |
| Bool | atOrBeyondEnd |
| IPosition | cursAxes |
| IPosition | iterationAxes |
| casa::ArrayPositionIterator::ArrayPositionIterator | ( | const IPosition & | shape, | |
| const IPosition & | origin, | |||
| uInt | byDim | |||
| ) |
Define the shape and origin of the volume the cursor will step through.
Also define the dimensionality of the step. byDim==0 implies we are stepping by scalars (i.e. every element), byDim==1 implies that we are stepping by vector, ==2 by matrices, and so on. If uses the first byDim axes as the cursor volume and it steps through the remaining axes.
| casa::ArrayPositionIterator::ArrayPositionIterator | ( | const IPosition & | shape, | |
| const IPosition & | axes, | |||
| Bool | axesAreCursor = True | |||
| ) |
Step through an array using the given axes.
The axes can be given in two ways:
| virtual casa::ArrayPositionIterator::~ArrayPositionIterator | ( | ) | [inline, virtual] |
Definition at line 117 of file ArrayPosIter.h.
| casa::ArrayPositionIterator::ArrayPositionIterator | ( | const IPosition & | shape, | |
| const IPosition & | origin, | |||
| uInt | byDim | |||
| ) |
Define the shape and origin of the volume the cursor will step through.
Also define the dimensionality of the step. byDim==0 implies we are stepping by scalars (i.e. every element), byDim==1 implies that we are stepping by vector, ==2 by matrices, and so on. If uses the first byDim axes as the cursor volume and it steps through the remaining axes.
| virtual void casa::ArrayPositionIterator::reset | ( | ) | [virtual] |
| void casa::ArrayPositionIterator::origin | ( | ) | [inline] |
| Bool casa::ArrayPositionIterator::atStart | ( | ) | const |
Returns true of the cursor is at the origin.
| Bool casa::ArrayPositionIterator::pastEnd | ( | ) | const [inline] |
We are at the "end" if we cannot advance any more.
Definition at line 177 of file ArrayPosIter.h.
References atOrBeyondEnd.
| const IPosition& casa::ArrayPositionIterator::pos | ( | ) | const [inline] |
Return the position of the cursor.
Definition at line 133 of file ArrayPosIter.h.
References Cursor.
| IPosition casa::ArrayPositionIterator::endPos | ( | ) | const |
Return the end position of the cursor.
| virtual void casa::ArrayPositionIterator::next | ( | ) | [virtual] |
Advance the cursor to its next position.
| uInt casa::ArrayPositionIterator::ndim | ( | ) | const [inline] |
Dimensionality of the array we are iterating through.
Definition at line 171 of file ArrayPosIter.h.
References casa::IPosition::nelements(), and Start.
| const IPosition& casa::ArrayPositionIterator::iterAxes | ( | ) | const [inline] |
| const IPosition& casa::ArrayPositionIterator::cursorAxes | ( | ) | const [inline] |
| uInt casa::ArrayPositionIterator::nextStep | ( | ) | [protected] |
Advance cursor to its next position and tell which dimension stepped.
| uInt casa::ArrayPositionIterator::dimIter | ( | ) | const [inline, protected] |
What is the dimensionality of the "step" the cursor takes, i.e.
0 for scalars, 1 for vector, .\..\.
Definition at line 155 of file ArrayPosIter.h.
References cursAxes, and casa::IPosition::nelements().
| void casa::ArrayPositionIterator::setup | ( | uInt | byDim | ) | [private] |
Setup the object for the constructor.
IPosition casa::ArrayPositionIterator::Start [private] |
IPosition casa::ArrayPositionIterator::Shape [private] |
Definition at line 165 of file ArrayPosIter.h.
IPosition casa::ArrayPositionIterator::End [private] |
Definition at line 165 of file ArrayPosIter.h.
IPosition casa::ArrayPositionIterator::Cursor [private] |
1.5.1