rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWMultiIndex Class Reference
[Math Collections]

An n-dimensional index class for traversing arrays of arbitrary dimension. More...

#include <rw/array.h>

Inheritance diagram for RWMultiIndex:
RWMathVec< int > RWVecView RWDataView

List of all members.

Public Member Functions

 RWMultiIndex (const RWIntVec &n)
void operator++ ()
void operator++ (int)
 operator void * ()

Detailed Description

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)

Synopsis

 #include <rw/math/mtharray.h>            // Any array class will do
 for(RWMultiIndex i(n); i; ++i) { ... }   // n is an IntVec

Examples

 #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;
 }

Constructor & Destructor Documentation

RWMultiIndex::RWMultiIndex ( const RWIntVec n  ) 

Constructs an index to count from 0 to n.


Member Function Documentation

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 >.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.