public abstract class AbstractBasicMultiDimensionalArray<T> extends java.lang.Object implements MultiDimensionalAccess<T>, java.lang.Iterable<T>
Modifier and Type | Field and Description |
---|---|
protected MultiIndexLinearizer |
indexLinearizer |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBasicMultiDimensionalArray(int... sizes)
Constructor.
|
protected |
AbstractBasicMultiDimensionalArray(MultiIndexLinearizer linearizer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Indexable<T> |
asLinearArray() |
<R> Indexable<R> |
asLinearArray(Function1<R,T> copier) |
Indexable<T> |
asLinearArray(MultiIndexLinearizer.Sequencer sequencer) |
<R> Indexable<R> |
asLinearArray(MultiIndexLinearizer.Sequencer sequencer,
Function1<R,T> copier)
View this multi-dimensional array as a linear array.
|
MultiIndexLinearizer |
getIndexLinearizer()
Get the multi-index linearizer on which this multi-dimensional array is based.
|
int |
getNumDimensions()
Get the number of dimensions of this array
|
long |
getNumElements()
Get the combined number of elements in all dimensions.
|
int |
getSize(int dim)
Get the size of the given dimension.
|
int[] |
getSizes()
Get the sizes of the dimensions of this array.
|
java.util.Iterator<T> |
iterator()
Get an iterator over a linearized view of this multi-dimensional array.
|
java.util.Iterator<T> |
iterator(MultiIndexLinearizer.Sequencer sequencer)
Get an iterator over a linearized view of this multi-dimensional array.
|
void |
setFrom(java.util.Collection<? extends T> elements)
Set all elements in this multi-dimensional array from the given collection.
|
void |
setFrom(java.lang.Iterable<? extends T> elements)
Set all elements in this multi-dimensional array in high-fast order.
|
void |
setFrom(MultiIndexLinearizer.Sequencer sequencer,
java.lang.Iterable<? extends T> elements)
Set all elements in this multi-dimensional array in the order
defined by the sequencer.
|
protected int |
toLinear(int... indexes)
Get the linear index for the given multi-dimensional indexes.
|
java.util.ArrayList<T> |
toList()
Convert this multi-dimensional array into an array list.
|
<R> java.util.ArrayList<R> |
toList(Function1<R,T> copier)
Convert this multi-dimensional array into an array list
using a dedicated copier.
|
java.util.ArrayList<T> |
toList(MultiIndexLinearizer.Sequencer sequencer)
Convert this multi-dimensional array into an array list.
|
<R> java.util.ArrayList<R> |
toList(MultiIndexLinearizer.Sequencer sequencer,
Function1<R,T> copier)
Convert this multi-dimensional array into an array list.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
change, changeAll, changeAll, setAll, setElement, setFrom, setFrom
empty, getElement, linearized, visitAll, visitAll
@NotNull protected final MultiIndexLinearizer indexLinearizer
protected AbstractBasicMultiDimensionalArray(int... sizes)
sizes
- of the dimensions of this array,
e.g. (2, 3, 4
} will create
an oblong array with size 2 in the first,
size 3 in the second, and size 4 in the third
dimension, containing 2*3*4 = 24
elementsprotected AbstractBasicMultiDimensionalArray(@NotNull MultiIndexLinearizer linearizer)
linearizer
- multi index linearizer@NotNull public MultiIndexLinearizer getIndexLinearizer()
Please note that the linearizer for
protected int toLinear(int... indexes)
indexes
- indexespublic int getNumDimensions()
getNumDimensions
in interface MultiDimensional
public int getSize(int dim)
getSize
in interface MultiDimensional
dim
- dimension@NotNull public int[] getSizes()
getSizes
in interface MultiDimensional
getNumDimensions()
public long getNumElements()
getNumElements
in interface MultiDimensional
@NotNull public java.util.Iterator<T> iterator()
iterator(MultiIndexLinearizer.Sequencer)
with a high fast sequener
.iterator
in interface java.lang.Iterable<T>
@NotNull public java.util.Iterator<T> iterator(@NotNull MultiIndexLinearizer.Sequencer sequencer)
sequencer
- sequencer to use for iterating over this multi-dimensional array,
must provide the same dimensionspublic void setFrom(@NotNull java.util.Collection<? extends T> elements)
MultiDimensionalAccess.setFrom(MultiIndexLinearizer.Sequencer, Collection)
with a high fast sequener
.elements
- array elements with at least getNumElements()
elementspublic void setFrom(@NotNull java.lang.Iterable<? extends T> elements)
elements
- elements in order, at least getNumElements()
java.lang.IllegalArgumentException
- if there are not enough elements in the iterablepublic void setFrom(@NotNull MultiIndexLinearizer.Sequencer sequencer, @NotNull java.lang.Iterable<? extends T> elements)
setFrom
in interface MultiDimensionalAccess<T>
sequencer
- sequencer defining the order in which elements are setelements
- elements in order, at least getNumElements()
java.lang.IllegalArgumentException
- if there are not enough elements in the iterable@NotNull public Indexable<T> asLinearArray(@NotNull MultiIndexLinearizer.Sequencer sequencer)
@NotNull public <R> Indexable<R> asLinearArray(@NotNull MultiIndexLinearizer.Sequencer sequencer, @NotNull Function1<R,T> copier)
R
- result array element typesequencer
- sequencer defining the element order, its dimensional setup
has to fit this multi-dimensional array setupcopier
- copier used to copy over elements from this multi-dimensional array
when requested@NotNull public java.util.ArrayList<T> toList()
high fast order
with elements copied directly@NotNull public <R> java.util.ArrayList<R> toList(@NotNull Function1<R,T> copier)
R
- result list element typecopier
- copier used to copy over elements from this multi-dimensional array
to the returned listhigh fast order
@NotNull public java.util.ArrayList<T> toList(@NotNull MultiIndexLinearizer.Sequencer sequencer)
sequencer
- sequencer defining the element order, its dimensional setup
has to fit this multi-dimensional array setup@NotNull public <R> java.util.ArrayList<R> toList(@NotNull MultiIndexLinearizer.Sequencer sequencer, @NotNull Function1<R,T> copier)
R
- result list element typesequencer
- sequencer defining the element order, its dimensional setup
has to fit this multi-dimensional array setupcopier
- copier used to copy over elements from this multi-dimensional array
to the returned list