casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::ReadOnlyArrayIterator< T > Class Template Reference

Iterate a const Array cursor through a const Array. More...

#include <ArrayIter.h>

Public Member Functions

 ReadOnlyArrayIterator (const Array< T > &arr, uInt byDim=1)
 Step through array "arr" using a cursor of dimensionality "byDim". More...
 
 ReadOnlyArrayIterator (const Array< T > &arr, const IPosition &axes, Bool axesAreCursor=True)
 Step through an array for the given iteration axes. More...
 
void next ()
 Move the cursor to the next position. More...
 
void set (const IPosition &cursorPos)
 Set the cursor to the given position. More...
 
void reset ()
 Reset the cursor to the beginning. More...
 
void origin ()
 
const Array< T > & array ()
 Return the cursor. More...
 
Bool atStart () const
 The same as the functions in ArrayPositionIterator. More...
 
Bool pastEnd () const
 
const IPositionpos () const
 
IPosition endPos () const
 
uInt ndim () const
 

Private Member Functions

 ReadOnlyArrayIterator (const ReadOnlyArrayIterator< T > &)
 Not implemented. More...
 
ReadOnlyArrayIterator< T > & operator= (const ReadOnlyArrayIterator< T > &)
 

Private Attributes

ArrayIterator< T > ai
 

Detailed Description

template<class T>
class casacore::ReadOnlyArrayIterator< T >

Iterate a const Array cursor through a const Array.

Review Status

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

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();
}
}


Tip: 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;

Definition at line 174 of file ArrayIter.h.

Constructor & Destructor Documentation

template<class T>
casacore::ReadOnlyArrayIterator< T >::ReadOnlyArrayIterator ( const Array< T > &  arr,
uInt  byDim = 1 
)
inlineexplicit

Step through array "arr" using a cursor of dimensionality "byDim".

Definition at line 178 of file ArrayIter.h.

template<class T>
casacore::ReadOnlyArrayIterator< T >::ReadOnlyArrayIterator ( const Array< T > &  arr,
const IPosition axes,
Bool  axesAreCursor = True 
)
inline

Step through an array for the given iteration axes.

Definition at line 182 of file ArrayIter.h.

template<class T>
casacore::ReadOnlyArrayIterator< T >::ReadOnlyArrayIterator ( const ReadOnlyArrayIterator< T > &  )
private

Not implemented.

Member Function Documentation

template<class T>
const Array<T>& casacore::ReadOnlyArrayIterator< T >::array ( )
inline

Return the cursor.

(Perhaps we should have a fn() that returns a reference to the original array as well?)

Definition at line 207 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
Bool casacore::ReadOnlyArrayIterator< T >::atStart ( ) const
inline

The same as the functions in ArrayPositionIterator.

Definition at line 211 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
IPosition casacore::ReadOnlyArrayIterator< T >::endPos ( ) const
inline

Definition at line 214 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
uInt casacore::ReadOnlyArrayIterator< T >::ndim ( ) const
inline

Definition at line 215 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
void casacore::ReadOnlyArrayIterator< T >::next ( void  )
inline

Move the cursor to the next position.

Definition at line 187 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
ReadOnlyArrayIterator<T>& casacore::ReadOnlyArrayIterator< T >::operator= ( const ReadOnlyArrayIterator< T > &  )
private
template<class T>
void casacore::ReadOnlyArrayIterator< T >::origin ( )
inline

Definition at line 202 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
Bool casacore::ReadOnlyArrayIterator< T >::pastEnd ( ) const
inline

Definition at line 212 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
const IPosition& casacore::ReadOnlyArrayIterator< T >::pos ( ) const
inline

Definition at line 213 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
void casacore::ReadOnlyArrayIterator< T >::reset ( void  )
inline

Reset the cursor to the beginning.

Definition at line 201 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

template<class T>
void casacore::ReadOnlyArrayIterator< T >::set ( const IPosition cursorPos)
inline

Set the cursor to the given position.

The position can only contain the iteration axes or it can be the full position.
In the first case the position must to be given in the order of the iteration axes as given in the constructor. In the latter case the position must be given in natural order (as given by function pos and only the cursor axes are taken into account.

Definition at line 197 of file ArrayIter.h.

References casacore::ReadOnlyArrayIterator< T >::ai.

Member Data Documentation

template<class T>
ArrayIterator<T> casacore::ReadOnlyArrayIterator< T >::ai
private

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