tclindex

This class is used to index through a TCL array. TCL arrays can have arbitrary strings for indices, and are not necessarily ordered. The class has three main methods: start, which takes a tclvar variable that refers to the array, and returns the first element in the array; incr, which returns the next element of the array; and last which returns 1 if the last element has been read. A sample usage might be (for computing the product of all elements in the array dims):

tclvar dims="dims";
tclindex idx;
for (ncells *= (int)idx.start(dims); !idx.last(); ncells *= (int)idx.incr() );

The class definition is given by:

class tclindex  
{
public:
  tclindex();
  tclindex(tclindex&);
  ~tclindex() {done();}
  tclvar start(tclvar&);
  inline tclvar incr();
  tclvar incr(tclvar& x) {incr();}  
  int last();
};