public abstract class MDAbstractArray<T> extends java.lang.Object implements java.io.Serializable, java.lang.Iterable<MDAbstractArray.ArrayEntry>
int[]
.
The array can grow or shrink in the first dimension (dimensions[0]). Dimensions
1...n
are static. They are said to form a hyper-row.
Modifier and Type | Class and Description |
---|---|
class |
MDAbstractArray.ArrayEntry
A class to represent an entry (index and value) of a
MDArray , used for iteration. |
Modifier and Type | Method and Description |
---|---|
abstract int |
capacity()
Returns the capacity of elements in the array.
|
int |
computeIndex(int... indices)
Computes the linear index for the multi-dimensional indices provided.
|
int |
computeIndex(int indexX,
int indexY)
Computes the linear index for the two-dimensional (indexX, indexY) provided.
|
int |
computeIndex(int indexX,
int indexY,
int indexZ)
Computes the linear index for the three-dimensional (indexX, indexY, indexZ)
provided.
|
int[] |
computeReverseIndex(int linearIndex)
Computes the multi-dimensional index from the linearIndex.
|
int |
decNumberOfHyperRows(int count)
Decrease the number of hyper-rows by count.
|
int[] |
dimensions()
Returns a copy of the dimensions of the multi-dimensional array.
|
abstract java.lang.Object |
getAsFlatArray()
Returns the array in flattened form.
|
abstract T |
getAsObject(int... indices)
Return an object which has the same value as the element of the array specified by
indices.
|
abstract T |
getAsObject(int linearIndex)
Return an object which has the same value as the element of the array specified by
linearIndex.
|
abstract java.lang.Object |
getCopyAsFlatArray()
Returns a copy of the array in flattened form.
|
static int |
getLength(int[] dimensions)
Returns the one-dimensional length of the multi-dimensional array defined by
dimensions.
|
static int |
getLength(int[] dimensions,
int capacityHyperRows)
Returns the one-dimensional length of the multi-dimensional array defined by
dimensions.
|
static int |
getLength(long[] dimensions)
Returns the one-dimensional length of the multi-dimensional array defined by
dimensions.
|
static int |
getLength(long[] dimensions,
long capacityHyperRows)
Returns the one-dimensional length of the multi-dimensional array defined by
dimensions.
|
int |
incNumberOfHyperRows(int count)
Increase the number of hyper-rows by count.
|
java.util.Iterator<MDAbstractArray.ArrayEntry> |
iterator() |
long[] |
longDimensions()
Returns a copy of the dimensions of the multi-dimensional array as
long[] . |
int |
numberOfHyperRows()
Returns the current number of hyper rows of of this array.
|
int |
rank()
Returns the rank of the array.
|
abstract void |
setToObject(T value,
int... indices)
Sets the element of the array specified by indices to the particular
value.
|
abstract void |
setToObject(T value,
int linearIndex)
Sets the element of the array specified by linearIndex to the particular
value.
|
int |
size()
Returns the number of elements in the array.
|
int |
size(int dim)
Returns the extent of the array along its dim-th axis.
|
static int[] |
toInt(long[] dimensions)
Converts the dimensions from
long[] to int[] . |
static long[] |
toLong(int[] dimensions)
Converts the dimensions from
int[] to long[] . |
java.lang.String |
toString() |
public int rank()
public int size(int dim)
public int[] dimensions()
public long[] longDimensions()
long[]
.public int size()
public int numberOfHyperRows()
public abstract T getAsObject(int linearIndex)
linearIndex
- The index in the linear array returned by getAsFlatArray()
.public abstract T getAsObject(int... indices)
public abstract void setToObject(T value, int... indices)
public abstract void setToObject(T value, int linearIndex)
value
- The new value to set.linearIndex
- The index in the linear array returned by getAsFlatArray()
.public abstract java.lang.Object getAsFlatArray()
public abstract java.lang.Object getCopyAsFlatArray()
public abstract int capacity()
public int incNumberOfHyperRows(int count)
public int decNumberOfHyperRows(int count)
public int computeIndex(int... indices)
public int[] computeReverseIndex(int linearIndex)
public int computeIndex(int indexX, int indexY)
public int computeIndex(int indexX, int indexY, int indexZ)
public static int[] toInt(long[] dimensions)
long[]
to int[]
.public static long[] toLong(int[] dimensions)
int[]
to long[]
.public static int getLength(int[] dimensions)
java.lang.IllegalArgumentException
- If dimensions overflow the int
type.public static int getLength(int[] dimensions, int capacityHyperRows)
capacityHyperRows > dimensions[0]
, then it will
replace dimensions[0] by capacityHyperRowsjava.lang.IllegalArgumentException
- If dimensions overflow the int
type.public static int getLength(long[] dimensions)
java.lang.IllegalArgumentException
- If dimensions overflow the int
type.public static int getLength(long[] dimensions, long capacityHyperRows)
capacityHyperRows > dimensions[0]
, then it will
replace dimensions[0] by capacityHyperRowsjava.lang.IllegalArgumentException
- If dimensions overflow the int
type.public java.util.Iterator<MDAbstractArray.ArrayEntry> iterator()
iterator
in interface java.lang.Iterable<MDAbstractArray.ArrayEntry>
public java.lang.String toString()
toString
in class java.lang.Object