de.caff.generics.mda

## Class MappingMultiIndexLinearizer

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

- All Implemented Interfaces:
    MultiDimensional, MultiIndexLinearizer

      class MappingMultiIndexLinearizer
      extends java.lang.Object
      implements MultiIndexLinearizer

  Multi-index linearizer which provides an arbitrary mapping.

  Not public because automatically created when accessing sub arrays and therefore not fit for base arrays.

  Since:
    November 04, 2019
  Author:
    Rammi

- - ### Nested Class Summary

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

      `MultiIndexLinearizer.BasicSequencer, MultiIndexLinearizer.Sequencer`

  - ### Field Summary

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

      `OPEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MappingMultiIndexLinearizer(MultiIndexLinearizer baseIndexLinearizer, Function1<int[],int[]> mapper, int... sizes)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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`

- - ### Constructor Detail

    - #### MappingMultiIndexLinearizer

          MappingMultiIndexLinearizer(@NotNull
                                      MultiIndexLinearizer baseIndexLinearizer,
                                      @NotNull
                                      Function1<int[],int[]> mapper,
                                      int... sizes)

      Constructor.
      Parameters:
        `baseIndexLinearizer` - basic multi-index linearizer on which this linearizer maps
        `mapper` - mapper from incoming indexes to indexes the `baseIndexLinearizer` requires. Failing to fulfill the restrictions will result in runtime errors
        `sizes` - sizes of the dimensions this multi-index linea provides

  - ### Method Detail

    - #### 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

    - #### 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()`

    - #### 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