ACT Library
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Arraystep Class Reference

Class for stepping through an array. More...

#include <act_array.h>

Public Member Functions

 Arraystep (Array *a, Array *sub=NULL)
 
 ~Arraystep ()
 
void step ()
 advance to the next element in the array
 
int index ()
 
int index (Array *b)
 
int isend ()
 
int typesize ()
 
char * string (int style=0)
 
ArraytoArray ()
 
void Print (FILE *fp, int style=0)
 

Private Attributes

int idx
 used to track the current index
 
int * deref
 used to track the current array de-reference
 
Arraybase
 the base array
 
Arraysubrange
 the subrange, if any
 
Arrayinsubrange
 part of subrange walker state
 

Detailed Description

Class for stepping through an array.

This class is used for an ordered traversal of an array/sub-range of an array. Given an Array, we can use this in the following fashion:

Array *a = ...
Arraystep *as = a->stepper(); // to step through the entire array
while (!as->isend()) {
int idx = as->index(); // the index of the element
...
Array *elem = as->toArray(); // the array de-reference for the element
...
as->step(); // advance the stepper
}
delete as; // done with stepper
Dense arrays, sparse arrays, and array dereferences.
Definition: act_array.h:65
friend class Arraystep
Definition: act_array.h:443
Arraystep * stepper(Array *sub=NULL)
int idx
used to track the current index
Definition: act_array.h:512

Constructor & Destructor Documentation

◆ Arraystep()

Arraystep::Arraystep ( Array a,
Array sub = NULL 
)

Construct a stepper for the array a, with an optional sub-range specifier sub

Parameters
athe array to be stepped through
subis an optional sub-range of the array a of interest

◆ ~Arraystep()

Arraystep::~Arraystep ( )

Member Function Documentation

◆ index() [1/2]

int Arraystep::index ( )
inline

the linear index of the current element in the array being stepped through

◆ index() [2/2]

int Arraystep::index ( Array b)
inline

the index of the current de-reference within array b

◆ isend()

int Arraystep::isend ( )
Returns
1 on an end of array, 0 otherwise

◆ Print()

void Arraystep::Print ( FILE *  fp,
int  style = 0 
)

Print the current array de-reference to the specified file

Parameters
fpis the output file
styleis the array printing style

◆ step()

void Arraystep::step ( )

advance to the next element in the array

◆ string()

char * Arraystep::string ( int  style = 0)
Returns
a freshly allocated string corresponding to the current de-reference.

◆ toArray()

Array * Arraystep::toArray ( )

convert the current element de-reference into an Array class.

◆ typesize()

int Arraystep::typesize ( )
inline
Returns
the size of the array being stepped through

Member Data Documentation

◆ base

Array* Arraystep::base
private

the base array

◆ deref

int* Arraystep::deref
private

used to track the current array de-reference

◆ idx

int Arraystep::idx
private

used to track the current index

◆ insubrange

Array* Arraystep::insubrange
private

part of subrange walker state

◆ subrange

Array* Arraystep::subrange
private

the subrange, if any


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