ArrayIterator steps an array section (the "cursor") through an array. The cursor "refers" to storage in the array, so that changing the values in the cursor changes values in the original array. Like with ArrayPositionIterator, the cursor presently only moves through the array from bottom to top in the obvious way; however one may of course iterate through a slice ("array section"). This class is derived from ArrayPositionIterator since it also has a position (the blc of the cursor) which moves through the array volume.
The origin of the cursor, i.e. the subarray that moves through the larger array, is always zero.
Array<Float> to, from; //... set to and from, check that they are conformant ArrayIterator toiter(to,1); ArrayIterator fromiter(from,1); while (! toiter.pastEnd() ) { toiter.array() = fromiter.array(); // copy vector by vector toiter.next(); fromiter.next(); }
Move the cursor to the next position.
Return the cursor. (Perhaps we should have a fn() that returns a reference to the original array as well?)
This class behaves exactly like an ArrayIterator, only it iterates through const Arrays.
void CopyArray(Array<Float> &to, const Array<Float> &from) { //... check that they are conformant ArrayIterator toiter(to,1); ReadOnlyArrayIterator fromiter(from,1); while (! toiter.pastEnd() ) { toiter.array() = fromiter.array(); // copy vector by vector toiter.next(); fromiter.next(); } }
This class is not derived from ArrayPositionIterator. For simplicity it merely contains an ArrayIterator to which it forwards requests and returns (const) results. The iterator classes should be rethought and reimplemented.
Not implemented.
Move the cursor to the next position.
Reset the cursor to the beginning.
Return the cursor. (Perhaps we should have a fn() that returns a reference to the original array as well?)
The same as the function in ArrayPositionIterator.