Loading...
Searching...
No Matches
casacore::VectorIterator< T > Class Template Reference
casa package (libcasa_casa) » Arrays_module

More...

`#include <VectorIter.h>`

## Public Member Functions

| VectorIterator (Array< T > &a, size_t axis=0)
| Iterate by vector cursors through array "a".
Vector< T > & | vector ()
| Return a Vector at the current position.
Public Member Functions inherited from casacore::ArrayIterator< T >
| ArrayIterator (const Array< T > &arr, size_t byDim=1)
| Step through array "arr" over the first byDim axes (using a cursor of dimensionality "byDim").
| ArrayIterator (const Array< T > &arr, const IPosition &axes, bool axesAreCursor=true)
| Step through an array using the given axes.
virtual void | next () override
| Move the cursor to the next position.
virtual void | set (const IPosition &cursorPos) override
| Set the cursor to the given position.
virtual void | reset () override
| Reset the cursor to the beginning.
Array< T > & | array ()
| Return the cursor.
virtual ArrayBase & | getArray () override
| Get the array in the cursor.
Public Member Functions inherited from casacore::ArrayPositionIterator
| ArrayPositionIterator (const IPosition &shape, const IPosition &origin, size_t byDim)
| Define the shape and origin of the volume the cursor will step through.
| ArrayPositionIterator (const IPosition &shape, size_t byDim)
| ArrayPositionIterator (const IPosition &shape, const IPosition &axes, bool axesAreCursor=true)
| Step through an array using the given axes.
virtual | ~ArrayPositionIterator ()
void | origin ()
bool | atStart () const
| Returns true of the cursor is at the origin.
bool | pastEnd () const
| Returns true if the cursor has moved past the end of its volume.
const IPosition & | pos () const
| Return the position of the cursor.
IPosition | endPos () const
| Return the end position of the cursor.
size_t | ndim () const
| What is the dimensionality of the volume we are iterating through?
const IPosition & | iterAxes () const
| Return the iteration axes.
const IPosition & | cursorAxes () const
| Return the cursor axes.

## Private Member Functions

| VectorIterator (const VectorIterator< T > &)=delete
| Not implemented.
VectorIterator< T > & | operator= (const VectorIterator< T > &)=delete
| Not implemented.

## Additional Inherited Members

Protected Member Functions inherited from casacore::ArrayPositionIterator
size_t | nextStep ()
| Advance cursor to its next position and tell which dimension stepped.
size_t | dimIter () const
| What is the dimensionality of the "step" the cursor takes, i.e.
Protected Attributes inherited from casacore::ArrayIterator< T >
std::unique_ptr< Array< T > > | ap_p
| The cursor.

## Detailed Description

template<typename T>
class casacore::VectorIterator< T >

Iterate an Vector cursor through another Array.

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25

VectorIterator steps a Vector (the "cursor") through an array for the given axis. The cursor "refers" to storage in the array, so that changing the values in the cursor changes values in the original array.

This class is derived from ArrayIterator; basically it only adds the vector() member function which allows you to access the cursor as a Vector.

Tip: The origin of the cursor, i;e; the subarray that moves through the larger array, is always zero;

In this example we sum all the elements of an array; of course we already have the "sum" function in ArrayMath.h that we should use instead.

Array<float> af;
// set af
VectorIterator vi(af);
float sum = 0.0;
size_t n = vi.vector().nelements();
while (! vi.pastEnd()) {
for (int i=0; i < n; i++) { // N.B.; cursor always 0 based.
sum += vi.vector()(i);
}
vi.next();
}
casacore::Array
Definition Array.h:155
casacore::VectorIterator::VectorIterator
VectorIterator(Array< T > &a, size_t axis=0)
Iterate by vector cursors through array "a".
casacore::sum
LatticeExprNode sum(const LatticeExprNode &expr)

Definition at line 71 of file VectorIter.h.

## Constructor & Destructor Documentation

## VectorIterator() [1/2]

template<typename T>

casacore::VectorIterator< T >::VectorIterator | ( | Array< T > & | a,
|  | size_t | axis = 0 )

explicit

Iterate by vector cursors through array "a".

The vector cursor is taken for the given axis.

Referenced by operator=(), and VectorIterator().

## VectorIterator() [2/2]

template<typename T>

casacore::VectorIterator< T >::VectorIterator | ( | const VectorIterator< T > & |  | ) |

private delete

Not implemented.

References VectorIterator().

## Member Function Documentation

## operator=()

template<typename T>

VectorIterator< T > & casacore::VectorIterator< T >::operator= | ( | const VectorIterator< T > & |  | ) |

private delete

Not implemented.

References VectorIterator().

## vector()

template<typename T>

Vector< T > & casacore::VectorIterator< T >::vector | ( |  | ) |

inline

Return a Vector at the current position.

Definition at line 79 of file VectorIter.h.

References casacore::ArrayIterator< T >::ap_p.

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

- casa/Arrays/VectorIter.h