Package ch.systemsx.cisd.base.mdarray
Class MDByteArray
- java.lang.Object
-
- ch.systemsx.cisd.base.mdarray.MDAbstractArray<java.lang.Byte>
-
- ch.systemsx.cisd.base.mdarray.MDByteArray
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<MDAbstractArray.ArrayEntry>
public final class MDByteArray extends MDAbstractArray<java.lang.Byte>
A multi-dimensionalbyte
array.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ch.systemsx.cisd.base.mdarray.MDAbstractArray
MDAbstractArray.ArrayEntry
-
-
Field Summary
-
Fields inherited from class ch.systemsx.cisd.base.mdarray.MDAbstractArray
capacityHyperRows, dimensions, hyperRowLength, size
-
-
Constructor Summary
Constructors Constructor Description MDByteArray(byte[][] matrix)
Creates aMDByteArray
from the given matrix of rank 2.MDByteArray(byte[][] matrix, int[] dimensions)
Creates aMDByteArray
from the given matrix of rank 2 and the dimension which need to be less or equal the dimensions of matrix.MDByteArray(byte[] flattenedArray, int[] dimensions)
MDByteArray(byte[] flattenedArray, int[] dimensions, boolean checkdimensions)
Creates aMDByteArray
from the given flattenedArray and dimensions.MDByteArray(byte[] flattenedArray, long[] dimensions)
MDByteArray(byte[] flattenedArray, long[] dimensions, boolean checkdimensions)
Creates aMDByteArray
from the given flattenedArray and dimensions.MDByteArray(int[] dimensions)
Creates an emptyMDByteArray
with the dimensions.MDByteArray(int[] dimensions, int capacityHyperRows)
Creates an emptyMDByteArray
with the dimensions.MDByteArray(long[] dimensions)
Creates an emptyMDIntArray
with the dimensions.MDByteArray(long[] dimensions, long capacityHyperRows)
Creates an emptyMDByteArray
with the dimensions.MDByteArray(MDByteArray template)
Creates an independent copy (clone) of the template provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
adaptCapacityHyperRows()
int
capacity()
Returns the capacity of elements in the array.MDByteArray
clone()
boolean
equals(java.lang.Object obj)
byte
get(int index)
Returns the value of a one-dimensional array at the position defined by index.byte
get(int... indices)
Returns the value of array at the position defined by indices.byte
get(int indexX, int indexY)
Returns the value of a two-dimensional array at the position defined by indexX and indexY.byte
get(int indexX, int indexY, int indexZ)
Returns the value of a three-dimensional array at the position defined by indexX, indexY and indexZ.byte[]
getAsFlatArray()
Returns the array in flattened form.java.lang.Byte
getAsObject(int linearIndex)
Return an object which has the same value as the element of the array specified by linearIndex.java.lang.Byte
getAsObject(int... indices)
Return an object which has the same value as the element of the array specified by indices.byte[]
getCopyAsFlatArray()
Returns a copy of the array in flattened form.int
hashCode()
void
set(byte value, int index)
Sets the value of a one-dimension array at the position defined by index.void
set(byte value, int... indices)
Sets the value of array at the position defined by indices.void
set(byte value, int indexX, int indexY)
Sets the value of a two-dimensional array at the position defined by indexX and indexY.void
set(byte value, int indexX, int indexY, int indexZ)
Sets the value of a three-dimensional array at the position defined by indexX, indexY and indexZ.void
setToObject(java.lang.Byte value, int linearIndex)
Sets the element of the array specified by linearIndex to the particular value.void
setToObject(java.lang.Byte value, int... indices)
Sets the element of the array specified by indices to the particular value.byte[][]
toMatrix()
Creates and returns a matrix from a two-dimensional array.-
Methods inherited from class ch.systemsx.cisd.base.mdarray.MDAbstractArray
computeHyperRowLength, computeIndex, computeIndex, computeIndex, computeReverseIndex, decNumberOfHyperRows, dimensions, getLength, getLength, getLength, getLength, incNumberOfHyperRows, iterator, longDimensions, numberOfHyperRows, rank, size, size, toInt, toLong, toString
-
-
-
-
Constructor Detail
-
MDByteArray
public MDByteArray(long[] dimensions)
Creates an emptyMDIntArray
with the dimensions. Convenience method if dimensions are available aslong[]
.
-
MDByteArray
public MDByteArray(long[] dimensions, long capacityHyperRows)
Creates an emptyMDByteArray
with the dimensions. IfcapacityHyperRows > dimensions[0]
, then it will create an array with a capacity of capacityHyperRows hyper-rows. Convenience method if dimensions are available aslong[]
.
-
MDByteArray
public MDByteArray(byte[] flattenedArray, long[] dimensions)
Creates aMDByteArray
from the givenflattenedArray
anddimensions
. It is checked that the arguments are compatible. Convenience method if dimensions are available aslong[]
.
-
MDByteArray
public MDByteArray(byte[] flattenedArray, long[] dimensions, boolean checkdimensions)
Creates aMDByteArray
from the given flattenedArray and dimensions. If checkDimensions istrue
, it is checked that the arguments are compatible. Convenience method if dimensions are available aslong[]
.
-
MDByteArray
public MDByteArray(int[] dimensions)
Creates an emptyMDByteArray
with the dimensions.
-
MDByteArray
public MDByteArray(int[] dimensions, int capacityHyperRows)
Creates an emptyMDByteArray
with the dimensions. IfcapacityHyperRows > dimensions[0]
, then it will create an array with a capacity of capacityHyperRows hyper-rows.
-
MDByteArray
public MDByteArray(byte[] flattenedArray, int[] dimensions)
Creates aMDByteArray
from the givenflattenedArray
anddimensions
. It is checked that the arguments are compatible.
-
MDByteArray
public MDByteArray(byte[] flattenedArray, int[] dimensions, boolean checkdimensions)
Creates aMDByteArray
from the given flattenedArray and dimensions. If checkDimensions istrue
, it is checked that the arguments are compatible.
-
MDByteArray
public MDByteArray(byte[][] matrix)
Creates aMDByteArray
from the given matrix of rank 2. Note that the values in matrix will be copied and thus the createdMDIntArray
will be independent from matrix after construction.
-
MDByteArray
public MDByteArray(byte[][] matrix, int[] dimensions)
Creates aMDByteArray
from the given matrix of rank 2 and the dimension which need to be less or equal the dimensions of matrix. Note that the values in matrix will be copied and thus the createdMDIntArray
will be independent from matrix after construction.
-
MDByteArray
public MDByteArray(MDByteArray template)
Creates an independent copy (clone) of the template provided.
-
-
Method Detail
-
capacity
public int capacity()
Description copied from class:MDAbstractArray
Returns the capacity of elements in the array.- Specified by:
capacity
in classMDAbstractArray<java.lang.Byte>
-
getAsObject
public java.lang.Byte getAsObject(int... indices)
Description copied from class:MDAbstractArray
Return an object which has the same value as the element of the array specified by indices.- Specified by:
getAsObject
in classMDAbstractArray<java.lang.Byte>
-
setToObject
public void setToObject(java.lang.Byte value, int... indices)
Description copied from class:MDAbstractArray
Sets the element of the array specified by indices to the particular value.- Specified by:
setToObject
in classMDAbstractArray<java.lang.Byte>
-
getAsObject
public java.lang.Byte getAsObject(int linearIndex)
Description copied from class:MDAbstractArray
Return an object which has the same value as the element of the array specified by linearIndex.- Specified by:
getAsObject
in classMDAbstractArray<java.lang.Byte>
- Parameters:
linearIndex
- The index in the linear array returned byMDAbstractArray.getAsFlatArray()
.- Returns:
- The value at the specified index.
-
setToObject
public void setToObject(java.lang.Byte value, int linearIndex)
Description copied from class:MDAbstractArray
Sets the element of the array specified by linearIndex to the particular value.- Specified by:
setToObject
in classMDAbstractArray<java.lang.Byte>
- Parameters:
value
- The new value to set.linearIndex
- The index in the linear array returned byMDAbstractArray.getAsFlatArray()
.
-
getAsFlatArray
public byte[] getAsFlatArray()
Description copied from class:MDAbstractArray
Returns the array in flattened form. Changes to the returned object will change the multi-dimensional array directly.- Specified by:
getAsFlatArray
in classMDAbstractArray<java.lang.Byte>
-
getCopyAsFlatArray
public byte[] getCopyAsFlatArray()
Description copied from class:MDAbstractArray
Returns a copy of the array in flattened form. Changes to the returned object will not change the multi-dimensional array directly.- Specified by:
getCopyAsFlatArray
in classMDAbstractArray<java.lang.Byte>
-
adaptCapacityHyperRows
protected void adaptCapacityHyperRows()
- Specified by:
adaptCapacityHyperRows
in classMDAbstractArray<java.lang.Byte>
-
get
public byte get(int... indices)
Returns the value of array at the position defined by indices.
-
get
public byte get(int index)
Returns the value of a one-dimensional array at the position defined by index.Do not call for arrays other than one-dimensional!
-
get
public byte get(int indexX, int indexY)
Returns the value of a two-dimensional array at the position defined by indexX and indexY.Do not call for arrays other than two-dimensional!
-
get
public byte get(int indexX, int indexY, int indexZ)
Returns the value of a three-dimensional array at the position defined by indexX, indexY and indexZ.Do not call for arrays other than three-dimensional!
-
set
public void set(byte value, int... indices)
Sets the value of array at the position defined by indices.
-
set
public void set(byte value, int index)
Sets the value of a one-dimension array at the position defined by index.Do not call for arrays other than one-dimensional!
-
set
public void set(byte value, int indexX, int indexY)
Sets the value of a two-dimensional array at the position defined by indexX and indexY.Do not call for arrays other than two-dimensional!
-
set
public void set(byte value, int indexX, int indexY, int indexZ)
Sets the value of a three-dimensional array at the position defined by indexX, indexY and indexZ.Do not call for arrays other than three-dimensional!
-
toMatrix
public byte[][] toMatrix()
Creates and returns a matrix from a two-dimensional array.Do not call for arrays other than two-dimensional!
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
clone
public MDByteArray clone()
- Overrides:
clone
in classjava.lang.Object
-
-