public interface MultiIndexLinearizer extends MultiDimensional
Modifier and Type | Interface and Description |
---|---|
static class |
MultiIndexLinearizer.BasicSequencer
Basic implementation of a Sequencer.
|
static interface |
MultiIndexLinearizer.Sequencer
A sequencer creates a multi-index from a linear index.
|
Modifier and Type | Field and Description |
---|---|
static int |
OPEN
Special index used for open indexes.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkIndex(int dim,
int size,
int index)
Check a single index.
|
static void |
checkIndexes(int[] sizes,
int... indexes)
Check indexes whether they fulfill the basic restrictions.
|
default MultiIndexLinearizer.Sequencer |
getHighFastSequencer()
Get a sequencer will create a multi-index
by changing the highest dimension most fast.
|
default MultiIndexLinearizer.Sequencer |
getLowFastSequencer()
Get a sequencer will create a multi-index
by changing the lowest dimension most fast.
|
default MultiIndexLinearizer |
sub(int... fixedIndexes)
Get an indexer which indexes only a part of this
linearizer which is defined by keeping some indexes fix.
|
int |
toLinear(int... indexes)
Get the linear index which represents the given multi-dimensional index.
|
getNumDimensions, getNumElements, getSize, getSizes
static final int OPEN
sub(int...)
parameters to define an open index.int toLinear(int... indexes)
MultiDimensional.getNumElements()
when this linearizer only
represents a part of a larger-dimensional multi-index.
Good practice is to check the incoming index whether they fulfill
their bounds. Use checkIndexes(int[], int...)
for this.
indexes
- MultiDimensional.getNumDimensions()
indexes inside the ranges defined
by MultiDimensional.getSizes()
default MultiIndexLinearizer sub(int... fixedIndexes)
fixedIndexes
- non-negative values define fixed indexes of sub array,
OPEN
or other negative values are used
for indexes which can still be evalutated
by the returned linearizer@NotNull default MultiIndexLinearizer.Sequencer getHighFastSequencer()
For one-dimensional indexes it behaves the same as getLowFastSequencer()
.
Highest fast is the standard way in which multi-indexes are created, so using this sequencer on a non-sub indexer will iterate over the underlying sequence in its natural order allowing for caching effects.
@NotNull default MultiIndexLinearizer.Sequencer getLowFastSequencer()
getHighFastSequencer()
.static void checkIndexes(int[] sizes, int... indexes)
sizes
- sizes of the dimensions of an arrayindexes
- indexes into the dimensions of an arrayjava.lang.IllegalArgumentException
- if the lengths of both array differjava.lang.IndexOutOfBoundsException
- if the indexes don't fall into the boundsstatic void checkIndex(int dim, int size, int index)
dim
- dimension of the indexsize
- size of the dimensionindex
- indexjava.lang.IndexOutOfBoundsException
- if the indexes don't fall into the bounds