IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.MultiDimensionalArray< ElementType > Class Template Reference

Multidimensional arrays. More...

Public Member Functions

delegate void MultidimensionalArrayIterator< ElementType > (MultiDimensionalArray< ElementType > array, int[] indices, int currentLevel)
 Delegate that is used to do work at specific point in various methods that iterate over multidimensional arrays. More...
 
 MultiDimensionalArray (params int[] dimensions)
 Constructs a new multidimensional array with specified dimensions. More...
 
void ClearElements ()
 Sets all elements to the default value for the specific element type. More...
 
void SetDimensions (params int[] dimensions)
 Sets new dimensions of the current multidimensional array. More...
 
int Dimension (int which)
 Returns the specified dimension of the multidimensional array. More...
 
int GetLinearIndex (params int[] indices)
 Returns a linear index that corresponds to the specified table of indices, i.e. index of the element specified by these indices in the onedimensional data array. More...
 
int[] GetIndices (int linearIndex)
 Returns indices of the element whose linear index is specified (i.e. the index of element in the one dimensional data array that actually holds the data). More...
 
void Iterate (MultidimensionalArrayIterator< ElementType > beginLevel, MultidimensionalArrayIterator< ElementType > endLevel, MultidimensionalArrayIterator< ElementType > workElement)
 Iterates over all elements of the multdimensional array, and executes the specified delegates at different events. More...
 
string IndicesToStringNoBrackets (int[] indices)
 Creates and returns a string representation of indices as a plain comma separated list of integers in a single line (without brackets). More...
 
string IndicesToString (int[] indices)
 Creates and returns a string representation of indices as a comma separated list of integers in a single line and tightly embedded in curly brackets. More...
 
string ToStringSimple ()
 Returns a simple string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon. More...
 
string ToStringTest ()
 Returns a simple string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon. More...
 
string ToStringOld ()
 Returns a string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon. More...
 
override string ToString ()
 Returns a string representation of a multidimensional array in the Mathematica-like set notation. More...
 
string ToString (bool newLinesLast)
 Returns a string representation of a multidimensional array in the Mathematica-like set notation. More...
 

Static Public Member Functions

static void ExampleFillArray (MultiDimensionalArray< int > array)
 Fills the specified multidimensional array of integers in such a way that element values are related to positions within the array in a simple and easily identifiable way. More...
 
static void Example (params int[] dimensions)
 Example of use of multidimensional arrays. More...
 
static void Example ()
 Example of use of multidimensional arrays. More...
 

Public Attributes

int _numElements
 

Protected Member Functions

void IterateAux (int[] indices, int level, MultidimensionalArrayIterator< ElementType > beginLevel, MultidimensionalArrayIterator< ElementType > endLevel, MultidimensionalArrayIterator< ElementType > workElement)
 Auxiliary method for Iterate, recursive. More...
 

Protected Attributes

readonly object _lock = new object()
 
ElementType[] _data
 
int[] _dimensions
 
int _numIndices
 
int[] _subTableLengths
 Array of subtable lengths. Last element is always one. More...
 

Properties

object Lock [get]
 Object used for thread locking. More...
 
ElementType[] Data [get, set]
 Array containing data of the multidimensional array. More...
 
int[] Dimensions [get, set]
 Gets or sets dimensions of the multidimensional array. More...
 
int NumIndices [get]
 Gets numbet of indices of the multidimensional array. More...
 
int NumElements [get]
 Gets total number of elements of the multidimensional array. More...
 
int[] SubTableLengths [get]
 Gets an array of lengths of the subtables with specified number of indices defined. More...
 
ElementType this[params int[] indices [get, set]
 Index operator, gets or sets the specified element of the multidimensional array. More...
 

Private Member Functions

 MultiDimensionalArray ()
 Prevents calling argument-less constructor. More...
 

Detailed Description

Multidimensional arrays.

$A Igor xx;

Constructor & Destructor Documentation

IG.Lib.MultiDimensionalArray< ElementType >.MultiDimensionalArray ( )
inlineprivate

Prevents calling argument-less constructor.

IG.Lib.MultiDimensionalArray< ElementType >.MultiDimensionalArray ( params int[]  dimensions)
inline

Constructs a new multidimensional array with specified dimensions.

Parameters
dimensionsDimensions of the multidimensional array.

Can be null, meaning a zero rank array containing a sigle element.

Member Function Documentation

delegate void IG.Lib.MultiDimensionalArray< ElementType >.MultidimensionalArrayIterator< ElementType > ( MultiDimensionalArray< ElementType >  array,
int[]  indices,
int  currentLevel 
)

Delegate that is used to do work at specific point in various methods that iterate over multidimensional arrays.

Template Parameters
ElementTypeType of array element.
Parameters
arrayArray on which the method operates.
indicesIndices of the current element of sub-array.
currentLevelCurrent level of iteration. Starts with 0 for the level where outermost sub-arrays are iterated, until the number of dimensions where individual element is worked on.
void IG.Lib.MultiDimensionalArray< ElementType >.ClearElements ( )
inline

Sets all elements to the default value for the specific element type.

void IG.Lib.MultiDimensionalArray< ElementType >.SetDimensions ( params int[]  dimensions)
inline

Sets new dimensions of the current multidimensional array.

Parameters
dimensionsNew dimensions.

Setter of the index operator is used.

int IG.Lib.MultiDimensionalArray< ElementType >.Dimension ( int  which)
inline

Returns the specified dimension of the multidimensional array.

Parameters
whichSpecifies which dimension is returned.
int IG.Lib.MultiDimensionalArray< ElementType >.GetLinearIndex ( params int[]  indices)
inline

Returns a linear index that corresponds to the specified table of indices, i.e. index of the element specified by these indices in the onedimensional data array.

Parameters
indicesSet of indices that specify the desired element.

If the array has zero rank then indices can be null, in this case 0 is returned (pointing at teh only element).

int [] IG.Lib.MultiDimensionalArray< ElementType >.GetIndices ( int  linearIndex)
inline

Returns indices of the element whose linear index is specified (i.e. the index of element in the one dimensional data array that actually holds the data).

Parameters
linearIndexLinear index of the element in the one dimensional array of elements, for which the multidimensional index is returned.
void IG.Lib.MultiDimensionalArray< ElementType >.IterateAux ( int[]  indices,
int  level,
MultidimensionalArrayIterator< ElementType >  beginLevel,
MultidimensionalArrayIterator< ElementType >  endLevel,
MultidimensionalArrayIterator< ElementType >  workElement 
)
inlineprotected

Auxiliary method for Iterate, recursive.

This method is usually called by the Iterate method to iterate recursively over elements.

Parameters
indicesCurrent array of indices that selects a specific element (if level == NumIndices) or define the subtable over which to iterate in the next level.

Initial call (outermost recursion level) to this method should be with all indices equal to 0.

The first index is associated with the outer-most recursion level and varies most slowly durig recursion.

Parameters
levelCurrent level of iteration; starts with 0.

Initial call (outermost recursion level) to this method should be with level equal to 0.

Parameters
beginLevelDelegate that executes when a new level is begun. This is not executed for each single element, but only for subarrays.
endLeveldelegate that executes when a new level ends. This is not executed for each single element, but only for subarrays.
workElementDelegate that executes in the final level, for each element of the multidimensional array.

The level argument equals the number of indices that are fixed at the current recursion level.

The workElement delegate is executed only in the deepest recursion level when individual elements are worked. At this level, the level argument equals the number of array dimensions (i.e. NumIndices).

At the top-most iteration level (when the method is first called), the level parameter equals 0, and no indices are specified at this level.

void IG.Lib.MultiDimensionalArray< ElementType >.Iterate ( MultidimensionalArrayIterator< ElementType >  beginLevel,
MultidimensionalArrayIterator< ElementType >  endLevel,
MultidimensionalArrayIterator< ElementType >  workElement 
)
inline

Iterates over all elements of the multdimensional array, and executes the specified delegates at different events.

This is initiation method for iteration over elements, and the recursive method IterateAux is called to actually do the job. See that method for more detailed description.

Parameters
beginLevelExecuted when a new level begins. This is not executed for each single element, but only for subarrays.
endLevelExecuded when a new level ends. This is not executed for each single element, but only for subarrays.
workElementExecuted on each element (i.e. only on the last level).
string IG.Lib.MultiDimensionalArray< ElementType >.IndicesToStringNoBrackets ( int[]  indices)
inline

Creates and returns a string representation of indices as a plain comma separated list of integers in a single line (without brackets).

Parameters
indicesIndices whose string representation is returned.
string IG.Lib.MultiDimensionalArray< ElementType >.IndicesToString ( int[]  indices)
inline

Creates and returns a string representation of indices as a comma separated list of integers in a single line and tightly embedded in curly brackets.

Parameters
indicesIndices whose string representation is returned.
string IG.Lib.MultiDimensionalArray< ElementType >.ToStringSimple ( )
inline

Returns a simple string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon.

Returns
string IG.Lib.MultiDimensionalArray< ElementType >.ToStringTest ( )
inline

Returns a simple string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon.

Returns
string IG.Lib.MultiDimensionalArray< ElementType >.ToStringOld ( )
inline

Returns a string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon.

Returns
override string IG.Lib.MultiDimensionalArray< ElementType >.ToString ( )
inline

Returns a string representation of a multidimensional array in the Mathematica-like set notation.

Elements are written in nested curly brackets.

string IG.Lib.MultiDimensionalArray< ElementType >.ToString ( bool  newLinesLast)
inline

Returns a string representation of a multidimensional array in the Mathematica-like set notation.

Elements are written in nested curly brackets.

Parameters
newLinesLastIf true then elements of the last level are written with newlines between.
static void IG.Lib.MultiDimensionalArray< ElementType >.ExampleFillArray ( MultiDimensionalArray< int >  array)
inlinestatic

Fills the specified multidimensional array of integers in such a way that element values are related to positions within the array in a simple and easily identifiable way.

Parameters
array
static void IG.Lib.MultiDimensionalArray< ElementType >.Example ( params int[]  dimensions)
inlinestatic

Example of use of multidimensional arrays.

static void IG.Lib.MultiDimensionalArray< ElementType >.Example ( )
inlinestatic

Example of use of multidimensional arrays.

Member Data Documentation

readonly object IG.Lib.MultiDimensionalArray< ElementType >._lock = new object()
protected
ElementType [] IG.Lib.MultiDimensionalArray< ElementType >._data
protected
int [] IG.Lib.MultiDimensionalArray< ElementType >._dimensions
protected
int IG.Lib.MultiDimensionalArray< ElementType >._numIndices
protected
int IG.Lib.MultiDimensionalArray< ElementType >._numElements
int [] IG.Lib.MultiDimensionalArray< ElementType >._subTableLengths
protected

Array of subtable lengths. Last element is always one.

Property Documentation

object IG.Lib.MultiDimensionalArray< ElementType >.Lock
get

Object used for thread locking.

ElementType [] IG.Lib.MultiDimensionalArray< ElementType >.Data
getsetprotected

Array containing data of the multidimensional array.

int [] IG.Lib.MultiDimensionalArray< ElementType >.Dimensions
getset

Gets or sets dimensions of the multidimensional array.

Getter creates and returns a copy of internal dimensions.

int IG.Lib.MultiDimensionalArray< ElementType >.NumIndices
get

Gets numbet of indices of the multidimensional array.

int IG.Lib.MultiDimensionalArray< ElementType >.NumElements
get

Gets total number of elements of the multidimensional array.

int [] IG.Lib.MultiDimensionalArray< ElementType >.SubTableLengths
get

Gets an array of lengths of the subtables with specified number of indices defined.

Getter creates and returns a copy of internal subtable lengths.

ElementType this[params int[] IG.Lib.MultiDimensionalArray< ElementType >.indices
getset

Index operator, gets or sets the specified element of the multidimensional array.

A single index can be specified, treated as linear index of the element in the data array.

Parameters
indicesIndices that specify the element of the multidimensional array.

Can either be a full set of indices, or only one linear index (or array with one element) indicating the index of the element in the internal one dimensional data array.

If the array is zero rank then indices can be null.


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