SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
An n-dimensional
index class for traversing arrays of arbitrary dimension.
More...
#include <rw/array.h>
Public Member Functions | |
RWMultiIndex (const RWIntVec &n) | |
void | operator++ () |
void | operator++ (int) |
operator void * () |
Class RWMultiIndex is an n-dimensional
index class. It is a tool for traversing arrays of arbitrary dimension. As shown in the Example below, you can use RWMultiIndex to help you write subroutines that operate on arrays of arbitrary dimension. Using automatic type conversion, you can then call these subroutines with vectors, matrices, or arrays. For instance, you can use the Example subroutine as follows:
RWMathVec<int> v; RWGenMat<int> A; RWMathArray<int> X; . . . int vZeros = numZeros(v); int AZeros = numZeros(A); int XZeros = numZeros(X)
#include <rw/math/mtharray.h> // Any array class will do for(RWMultiIndex i(n); i; ++i) { ... } // n is an IntVec
#include <rw/math/mtharray.h> int numZeros(const RWMathArray<int>& X) // Count the number // of zeros in X { int count=0; for(RWMultiIndex i(X.length()); i; ++i) { if (X(i)==0) ++count; } return count; }
RWMultiIndex::RWMultiIndex | ( | const RWIntVec & | n | ) |
Constructs an index to count from 0 to n.
RWMultiIndex::operator void * | ( | ) | [inline] |
Returns 0 if the index is no longer valid. An index becomes invalid when it is incremented beyond its limit.
void RWMultiIndex::operator++ | ( | int | ) | [inline] |
Increments the index.
Reimplemented from RWMathVec< int >.
void RWMultiIndex::operator++ | ( | ) |
Increments the index.
Reimplemented from RWMathVec< int >.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.