IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
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... | |
Multidimensional arrays.
$A Igor xx;
|
inlineprivate |
Prevents calling argument-less constructor.
|
inline |
Constructs a new multidimensional array with specified dimensions.
dimensions | Dimensions of the multidimensional array. |
Can be null, meaning a zero rank array containing a sigle element.
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.
ElementType | Type of array element. |
array | Array on which the method operates. |
indices | Indices of the current element of sub-array. |
currentLevel | Current 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. |
|
inline |
Sets all elements to the default value for the specific element type.
|
inline |
Sets new dimensions of the current multidimensional array.
dimensions | New dimensions. |
Setter of the index operator is used.
|
inline |
Returns the specified dimension of the multidimensional array.
which | Specifies which dimension is returned. |
|
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.
indices | Set 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).
|
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).
linearIndex | Linear index of the element in the one dimensional array of elements, for which the multidimensional index is returned. |
|
inlineprotected |
Auxiliary method for Iterate, recursive.
This method is usually called by the Iterate method to iterate recursively over elements.
indices | Current 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.
level | Current level of iteration; starts with 0. |
Initial call (outermost recursion level) to this method should be with level equal to 0.
beginLevel | Delegate that executes when a new level is begun. This is not executed for each single element, but only for subarrays. |
endLevel | delegate that executes when a new level ends. This is not executed for each single element, but only for subarrays. |
workElement | Delegate 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.
|
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.
beginLevel | Executed when a new level begins. This is not executed for each single element, but only for subarrays. |
endLevel | Execuded when a new level ends. This is not executed for each single element, but only for subarrays. |
workElement | Executed on each element (i.e. only on the last level). |
|
inline |
Creates and returns a string representation of indices as a plain comma separated list of integers in a single line (without brackets).
indices | Indices whose string representation is returned. |
|
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.
indices | Indices whose string representation is returned. |
|
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.
|
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.
|
inline |
Returns a string representation of a multidimensional array. Each element is written in its own line starting with element indices and a colon.
|
inline |
Returns a string representation of a multidimensional array in the Mathematica-like set notation.
Elements are written in nested curly brackets.
|
inline |
Returns a string representation of a multidimensional array in the Mathematica-like set notation.
Elements are written in nested curly brackets.
newLinesLast | If true then elements of the last level are written with newlines between. |
|
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.
array |
|
inlinestatic |
Example of use of multidimensional arrays.
|
inlinestatic |
Example of use of multidimensional arrays.
|
protected |
|
protected |
|
protected |
|
protected |
int IG.Lib.MultiDimensionalArray< ElementType >._numElements |
|
protected |
Array of subtable lengths. Last element is always one.
|
get |
Object used for thread locking.
|
getsetprotected |
Array containing data of the multidimensional array.
|
getset |
Gets or sets dimensions of the multidimensional array.
Getter creates and returns a copy of internal dimensions.
|
get |
Gets numbet of indices of the multidimensional array.
|
get |
Gets total number of elements of the multidimensional array.
|
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.
|
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.
indices | Indices 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.