de.caff.generics.mda

## Class LowFastMultiIndexLinearizer

- java.lang.Object
- - de.caff.generics.mda.LowFastMultiIndexLinearizer

- All Implemented Interfaces:
    MultiDimensional, MultiIndexLinearizer

      public class LowFastMultiIndexLinearizer
      extends java.lang.Object
      implements MultiIndexLinearizer

  Simple lowest-index fast implementation of a multi-index linearizer. It maps indexes of the lowest dimension to be separated by `1`. So iterating over these might result in caching effects.
  Since:
    November 01, 2019
  Author:
    Rammi

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface de.caff.generics.mda.MultiIndexLinearizer

      `MultiIndexLinearizer.BasicSequencer, MultiIndexLinearizer.Sequencer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) int[]` | `sizes` The sizes of the dimensions of this array.

    - ### Fields inherited from interface de.caff.generics.mda.MultiIndexLinearizer

      `OPEN`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `LowFastMultiIndexLinearizer(int... sizes)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int[]` | `fromLinear(int linearIndex)` Get the multi-dimensional index mapped to a given linear index.
    `int` | `getNumDimensions()` Get the number of dimensions used by this access,
    `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 access.
    `int` | `toLinear(int... indexes)` Get the linear index which represents the given multi-dimensional index.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface de.caff.generics.mda.MultiIndexLinearizer

      `checkIndex, checkIndexes, getHighFastSequencer, getLowFastSequencer, sub`

- - ### Field Detail

    - #### sizes

          @NotNull
          final int[] sizes

      The sizes of the dimensions of this array.

  - ### Constructor Detail

    - #### LowFastMultiIndexLinearizer

          protected LowFastMultiIndexLinearizer(int... sizes)

      Constructor.
      Parameters:
        `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` elements

  - ### Method Detail

    - #### getNumDimensions

          public int getNumDimensions()

      Description copied from interface: `MultiDimensional`
      Get the number of dimensions used by this access,
      Specified by:
        `getNumDimensions` in interface `MultiDimensional`
      Returns:
        number of dimensions

    - #### getSize

          public int getSize(int dim)

      Description copied from interface: `MultiDimensional`
      Get the size of the given dimension.
      Specified by:
        `getSize` in interface `MultiDimensional`
      Parameters:
        `dim` - dimension, greater than `0` and less than `MultiDimensional.getNumDimensions()`
      Returns:
        number of elements in the given dimension

    - #### getSizes

          @NotNull
          public int[] getSizes()

      Description copied from interface: `MultiDimensional`
      Get the sizes of the dimensions of this access.
      Specified by:
        `getSizes` in interface `MultiDimensional`
      Returns:
        array of length `MultiDimensional.getNumDimensions()`

    - #### toLinear

          public int toLinear(int... indexes)

      Description copied from interface: `MultiIndexLinearizer`
      Get the linear index which represents the given multi-dimensional index. Please note that the returned values may fall outside of the range defined by `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 `MultiIndexLinearizer.checkIndexes(int[], int...)` for this.

      Specified by:
        `toLinear` in interface `MultiIndexLinearizer`
      Parameters:
        `indexes` - `MultiDimensional.getNumDimensions()` indexes inside the ranges defined by `MultiDimensional.getSizes()`
      Returns:
        linearized index

    - #### getNumElements

          public long getNumElements()

      Description copied from interface: `MultiDimensional`
      Get the combined number of elements in all dimensions.
      Specified by:
        `getNumElements` in interface `MultiDimensional`
      Returns:
        number of all elements in this multi-dimensional array

    - #### fromLinear

          @NotNull
          public int[] fromLinear(int linearIndex)

      Get the multi-dimensional index mapped to a given linear index.
      Parameters:
        `linearIndex` - linear index between `0` (included) and `getNumElements()` (excluded)
      Returns:
        multi-dimensional indexes which will be mapped to `linearIndex`