Previous: SIn_Array Example, Up: SIn Array Object
A sparse array with elements of type T. The number of elements the array can hold is equal to the number of static instructions in the benchmark program (the value of RSIM global variable
num_all_instructions). Initially the array has zero elements. Elements are automatically created using thegetfunction or[]operator. Thepeekfunction can be used to check whether an element is present (unlikegetit won't create one). Functiondeldeletes elements. Functioniteratecan be used in loops that need to examine each element.
int iiSIn* sinDIn* dinint iiSIn* sinDIn* dinIf not present at ii, instantiate object of type T and store it there. Return a pointer to the object. In first form the instruction index is given (ii). In second and third forms instruction index is determined using the argument. The last three are operator versions of the first three.
// The four lines below are equivalent. // Diff_SIn_Info* const si = sin_info[din]; Diff_SIn_Info* const si = sin_info.get(din); Diff_SIn_Info* const si = sin_info[din->pc]; Diff_SIn_Info* const si = sin_info[din->sin];
int iiSIn* sinDIn* dinIf not present at ii return NULL, otherwise return a pointer to the object. Value for ii computed in same way as
get.
void SIn_Array<T>::del int iivoid SIn_Array<T>::del SIn* sinvoid SIn_Array<T>::del DIn* dinIf there is an element at ii, sin, or din delete it.
void SIn_Array<T>::resetDelete all elements and reset iterator. This might be used before re-reading data from a
Profileobject.
bool SIn_Array::iterate int& idxThe first form returns an element of the array, or
NULL. The second form will either set idx to the instruction index of an element of the array and returntrueor it will returnfalse. Suppose the array contains five elements. The first call ofiteratewill return the first element (the one with the lowest index), the second call will return the second element, and so on. The sixth call will returnNULL(orfalse). The seventh call will return the first element, starting the sequence again.// Each loop iterates over all members of sin_info. for( int ii; sin_info.iterate(ii); ) { Diff_SIn_Info* const si = sin_info[ii]; total_exec += si->exe_count; } while ( Diff_SIn_Info* const si = sin_info.iterate() ) total_exec += si->exe_count;
void SIn_Array::iterate_resetReset the iteration state so that a subsequent call to
iteratewill return the first element.
int SIn_Array::iterate_get_iit_ptru SIn_Array::iterate_get_pcSIn* SIn_Array::iterate_get_sinThe first form returns the index of the last element returned by
iterate, the second form returns the program counter, and the third form returns a pointer to theSInstructure.