casacore
Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::ReadOnlyArrayIterator< T, Alloc > Class Template Reference

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

#include <ArrayIter.h>

Public Member Functions

 ReadOnlyArrayIterator (const Array< T, Alloc > &arr, size_t byDim=1)
 Step through array "arr" using a cursor of dimensionality "byDim". More...
 
 ReadOnlyArrayIterator (const Array< T, Alloc > &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, Alloc > & 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
 
size_t ndim () const
 

Private Member Functions

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

Private Attributes

ArrayIterator< T, Alloc > ai
 

Detailed Description

template<typename T, typename Alloc = std::allocator<T>>
class casacore::ReadOnlyArrayIterator< T, Alloc >

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();
}
}
ReadOnlyArrayIterator(const Array< T, Alloc > &arr, size_t byDim=1)
Step through array "arr" using a cursor of dimensionality "byDim".
Definition: ArrayIter.h:175


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 171 of file ArrayIter.h.

Constructor & Destructor Documentation

◆ ReadOnlyArrayIterator() [1/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::ReadOnlyArrayIterator< T, Alloc >::ReadOnlyArrayIterator ( const Array< T, Alloc > &  arr,
size_t  byDim = 1 
)
inlineexplicit

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

Definition at line 175 of file ArrayIter.h.

◆ ReadOnlyArrayIterator() [2/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::ReadOnlyArrayIterator< T, Alloc >::ReadOnlyArrayIterator ( const Array< T, Alloc > &  arr,
const IPosition axes,
bool  axesAreCursor = true 
)
inline

Step through an array for the given iteration axes.

Definition at line 179 of file ArrayIter.h.

◆ ReadOnlyArrayIterator() [3/3]

template<typename T , typename Alloc = std::allocator<T>>
casacore::ReadOnlyArrayIterator< T, Alloc >::ReadOnlyArrayIterator ( const ReadOnlyArrayIterator< T, Alloc > &  )
private

Not implemented.

Member Function Documentation

◆ array()

template<typename T , typename Alloc = std::allocator<T>>
const Array<T, Alloc>& casacore::ReadOnlyArrayIterator< T, Alloc >::array ( )
inline

Return the cursor.

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

Definition at line 204 of file ArrayIter.h.

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

Referenced by casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialArrayMath().

◆ atStart()

template<typename T , typename Alloc = std::allocator<T>>
bool casacore::ReadOnlyArrayIterator< T, Alloc >::atStart ( ) const
inline

The same as the functions in ArrayPositionIterator.

Definition at line 208 of file ArrayIter.h.

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

◆ endPos()

template<typename T , typename Alloc = std::allocator<T>>
IPosition casacore::ReadOnlyArrayIterator< T, Alloc >::endPos ( ) const
inline

Definition at line 211 of file ArrayIter.h.

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

◆ ndim()

template<typename T , typename Alloc = std::allocator<T>>
size_t casacore::ReadOnlyArrayIterator< T, Alloc >::ndim ( ) const
inline

Definition at line 212 of file ArrayIter.h.

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

◆ next()

template<typename T , typename Alloc = std::allocator<T>>
void casacore::ReadOnlyArrayIterator< T, Alloc >::next ( )
inline

◆ operator=()

template<typename T , typename Alloc = std::allocator<T>>
ReadOnlyArrayIterator<T, Alloc>& casacore::ReadOnlyArrayIterator< T, Alloc >::operator= ( const ReadOnlyArrayIterator< T, Alloc > &  )
private

◆ origin()

template<typename T , typename Alloc = std::allocator<T>>
void casacore::ReadOnlyArrayIterator< T, Alloc >::origin ( )
inline

Definition at line 199 of file ArrayIter.h.

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

◆ pastEnd()

template<typename T , typename Alloc = std::allocator<T>>
bool casacore::ReadOnlyArrayIterator< T, Alloc >::pastEnd ( ) const
inline

◆ pos()

template<typename T , typename Alloc = std::allocator<T>>
const IPosition& casacore::ReadOnlyArrayIterator< T, Alloc >::pos ( ) const
inline

Definition at line 210 of file ArrayIter.h.

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

◆ reset()

template<typename T , typename Alloc = std::allocator<T>>
void casacore::ReadOnlyArrayIterator< T, Alloc >::reset ( )
inline

Reset the cursor to the beginning.

Definition at line 198 of file ArrayIter.h.

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

◆ set()

template<typename T , typename Alloc = std::allocator<T>>
void casacore::ReadOnlyArrayIterator< T, Alloc >::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 194 of file ArrayIter.h.

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

Member Data Documentation

◆ ai

template<typename T , typename Alloc = std::allocator<T>>
ArrayIterator<T, Alloc> casacore::ReadOnlyArrayIterator< T, Alloc >::ai
private

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