de.caff.generics.mda

## Interface TwoDimensionalReadAccess<T>

- All Superinterfaces:
    MultiDimensional, MultiDimensionalReadAccess<T>
  All Known Subinterfaces:
    TwoDimensionalAccess<T>, TwoDimensionalBooleanAccess, TwoDimensionalBooleanReadAccess, TwoDimensionalByteAccess, TwoDimensionalByteReadAccess, TwoDimensionalCharAccess, TwoDimensionalCharReadAccess, TwoDimensionalDoubleAccess, TwoDimensionalDoubleReadAccess, TwoDimensionalFloatAccess, TwoDimensionalFloatReadAccess, TwoDimensionalIntAccess, TwoDimensionalIntReadAccess, TwoDimensionalLongAccess, TwoDimensionalLongReadAccess, TwoDimensionalShortAccess, TwoDimensionalShortReadAccess
  All Known Implementing Classes:
    SmallTwoDimensionalArray, SmallTwoDimensionalBitArray, SmallTwoDimensionalBooleanArray, SmallTwoDimensionalByteArray, SmallTwoDimensionalCharArray, SmallTwoDimensionalDoubleArray, SmallTwoDimensionalFloatArray, SmallTwoDimensionalIntArray, SmallTwoDimensionalLongArray, SmallTwoDimensionalShortArray, TwoDimensionalArray, TwoDimensionalBooleanArray, TwoDimensionalBooleanReadAccess.Base, TwoDimensionalByteArray, TwoDimensionalByteReadAccess.Base, TwoDimensionalCharArray, TwoDimensionalCharReadAccess.Base, TwoDimensionalDoubleArray, TwoDimensionalDoubleReadAccess.Base, TwoDimensionalFloatArray, TwoDimensionalFloatReadAccess.Base, TwoDimensionalIntArray, TwoDimensionalIntReadAccess.Base, TwoDimensionalLongArray, TwoDimensionalLongReadAccess.Base, TwoDimensionalReadAccess.Base, TwoDimensionalShortArray, TwoDimensionalShortReadAccess.Base

      public interface TwoDimensionalReadAccess<T>
      extends MultiDimensionalReadAccess<T>

  Read access for 2-dimensional rectangular arrays.
  Since:
    November 11, 2019
  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `TwoDimensionalReadAccess.Base<TT>` Base class implementing this interface which provides useful default methods for `Object.toString()`, `Object.equals(Object)`, and `Object.hashCode()`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TwoDimensionalReadAccess<?>` | `EMPTY` Empty acces, use `empty()` instead.

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

      `EMPTY0, EMPTY1, EMPTY2, EMPTY3, EMPTY4, EMPTY5, EMPTY6, EMPTY7`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default TwoDimensionalReadAccess.Base<T>` | `asBase()` View this class as if it has useful defaults for standard object methods.
    `static <E> TwoDimensionalReadAccess<E>` | `empty()` Get an empty 2dimensional read access.
    `static <E> boolean` | `equal(TwoDimensionalReadAccess<? extends E> access1, TwoDimensionalReadAccess<? extends E> access2, java.util.function.BiPredicate<E,E> equalityChecker)` Are two 2-dimensional accesses equal?
    `default T` | `getElement(int... indexes)` Get the element located at the given indexes.
    `T` | `getElementAt(int ix, int iy)` Get the element at the given indexes.
    `default int` | `getNumDimensions()` Get the number of dimensions used by this access,
    `default long` | `getNumElements()` Get the combined number of elements in all dimensions.
    `default int` | `getSize(int dim)` Get the size of the given dimension.
    `default int[]` | `getSizes()` Get the sizes of the dimensions of this access.
    `static int` | `hash(TwoDimensionalReadAccess<?> access)` Calculate a hashcode for a 2-dimensional read access..
    `static <E> TwoDimensionalReadAccess<E>` | `singleton(E singleElement)` Get a 2dimensional read access for a single element.
    `int` | `sizeX()` Get the number of elements in X direction.
    `int` | `sizeY()` Get the number of elements in Y direction
    `default OneDimensionalReadAccess<T>` | `subAtX(int ix)` Get a 1-dimensional view of the row at the given X index.
    `default OneDimensionalReadAccess<T>` | `subAtY(int iy)` Get a 1-dimensional view of the column at the given X index.
    `static java.lang.String` | `toString(TwoDimensionalReadAccess<?> access)` Create a string representation of an 2-dimensional read access.
    `default TwoDimensionalReadAccess<T>` | `transposed()` Get a transposed view of this 2-dimensional read access.
    `default <TOUT> TwoDimensionalReadAccess<TOUT>` | `view(java.util.function.Function<T,TOUT> conv)` Get a view of this two dimensional array with converted elements.
    `default void` | `visitAll(Procedure1<? super T> visitor)` Visit all elements in this multi-dimensional array.
    `default void` | `visitAll(Procedure2<? super T,int[]> visitor)` Visit all elements of this multi-dimensional array.
    `default java.lang.Iterable<OneDimensionalReadAccess<T>>` | `xIterable()` Get an iterable which iterates over rows with constant X.
    `default java.util.Iterator<OneDimensionalReadAccess<T>>` | `xIterator()` Get an iterator which iterates over rows with cnnstant X.
    `default java.lang.Iterable<OneDimensionalReadAccess<T>>` | `yIterable()` Get an iterable which iterates over rows with constant Y.
    `default java.util.Iterator<OneDimensionalReadAccess<T>>` | `yIterator()` Get an iterator which iterates over rows with cnnstant Y.

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

      `empty, linearized`

- - ### Field Detail

    - #### EMPTY

          static final TwoDimensionalReadAccess<?> EMPTY

      Empty acces, use `empty()` instead.

  - ### Method Detail

    - #### sizeX

          int sizeX()

      Get the number of elements in X direction.
      Returns:
        number of elements in X direction

    - #### sizeY

          int sizeY()

      Get the number of elements in Y direction
      Returns:
        number of elements in Y direction

    - #### getElementAt

          T getElementAt(int ix,
                         int iy)

      Get the element at the given indexes.
      Parameters:
        `ix` - index in X direction from `0` (included) to `sizeX()` (excluded)
        `iy` - index in Y direction from `0` (included) to `sizeY()` (excluded)
      Returns:
        element at the given indexes

    - #### getElement

          default T getElement(int... indexes)

      Description copied from interface: `MultiDimensionalReadAccess`
      Get the element located at the given indexes.
      Specified by:
        `getElement` in interface `MultiDimensionalReadAccess<T>`
      Parameters:
        `indexes` - `MultiDimensional.getNumDimensions()` indexes inside the bounds defined by `MultiDimensional.getSizes()`
      Returns:
        element located at the given indexes

    - #### subAtX

          @NotNull
          default OneDimensionalReadAccess<T> subAtX(int ix)

      Get a 1-dimensional view of the row at the given X index. This is a view, so setting elements will change values in this array.
      Parameters:
        `ix` - X index
      Returns:
        1-dimensional array at `ix`

    - #### xIterator

          @NotNull
          default java.util.Iterator<OneDimensionalReadAccess<T>> xIterator()

      Get an iterator which iterates over rows with cnnstant X.
      Returns:
        X row iterator

    - #### xIterable

          @NotNull
          default java.lang.Iterable<OneDimensionalReadAccess<T>> xIterable()

      Get an iterable which iterates over rows with constant X.
      Returns:
        X row iterable

    - #### yIterator

          @NotNull
          default java.util.Iterator<OneDimensionalReadAccess<T>> yIterator()

      Get an iterator which iterates over rows with cnnstant Y.
      Returns:
        Y row iterator

    - #### yIterable

          @NotNull
          default java.lang.Iterable<OneDimensionalReadAccess<T>> yIterable()

      Get an iterable which iterates over rows with constant Y.
      Returns:
        Y row iterable

    - #### subAtY

          @NotNull
          default OneDimensionalReadAccess<T> subAtY(int iy)

      Get a 1-dimensional view of the column at the given X index. This is a view, so setting elements will change values in this array.
      Parameters:
        `iy` - Y index
      Returns:
        1-dimensional array at `iy`

    - #### transposed

          @NotNull
          default TwoDimensionalReadAccess<T> transposed()

      Get a transposed view of this 2-dimensional read access.
      Returns:
        transposed view where X and Y are interchanged

    - #### getNumDimensions

          default 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

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

          default 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

    - #### view

          @NotNull
          default <TOUT> TwoDimensionalReadAccess<TOUT> view(@NotNull
                                                                      java.util.function.Function<T,TOUT> conv)

      Get a view of this two dimensional array with converted elements.
      Type Parameters:
        `TOUT` - element type provided by the view
      Parameters:
        `conv` - element converter
      Returns:
        view of this array with converted elements

    - #### visitAll

          default void visitAll(@NotNull
                                Procedure2<? super T,int[]> visitor)

      Description copied from interface: `MultiDimensionalReadAccess`
      Visit all elements of this multi-dimensional array.
      Specified by:
        `visitAll` in interface `MultiDimensionalReadAccess<T>`
      Parameters:
        `visitor` - visitor called with an array element and its multi-index

    - #### visitAll

          default void visitAll(@NotNull
                                Procedure1<? super T> visitor)

      Description copied from interface: `MultiDimensionalReadAccess`
      Visit all elements in this multi-dimensional array.
      Specified by:
        `visitAll` in interface `MultiDimensionalReadAccess<T>`
      Parameters:
        `visitor` - element visitor called once with each element

    - #### asBase

          @NotNull
          default TwoDimensionalReadAccess.Base<T> asBase()

      View this class as if it has useful defaults for standard object methods.
      Returns:
        based view of this class

    - #### toString

          @NotNull
          static java.lang.String toString(@NotNull
                                                    TwoDimensionalReadAccess<?> access)

      Create a string representation of an 2-dimensional read access.
      Parameters:
        `access` - access to stringify
      Returns:
        string representation

    - #### equal

          static <E> boolean equal(@NotNull
                                   TwoDimensionalReadAccess<? extends E> access1,
                                   @NotNull
                                   TwoDimensionalReadAccess<? extends E> access2,
                                   @NotNull
                                   java.util.function.BiPredicate<E,E> equalityChecker)

      Are two 2-dimensional accesses equal?
      Type Parameters:
        `E` - parameter type of equality checker, and super class of both accesses element type
      Parameters:
        `access1` - first access
        `access2` - second access
        `equalityChecker` - checker for equality of the elements of both objects
      Returns:
        `true` if both accesses contain the same values in the same sequence
        `false` if sizes or values differ

    - #### hash

          static int hash(@NotNull
                          TwoDimensionalReadAccess<?> access)

      Calculate a hashcode for a 2-dimensional read access..
      Parameters:
        `access` - access for which the hash code is required
      Returns:
        hash code for the given access

    - #### empty

          @NotNull
          static <E> TwoDimensionalReadAccess<E> empty()

      Get an empty 2dimensional read access.
      Type Parameters:
        `E` - element type
      Returns:
        `EMPTY` in a form the compiler accepts

    - #### singleton

          @NotNull
          static <E> TwoDimensionalReadAccess<E> singleton(E singleElement)

      Get a 2dimensional read access for a single element.
      Type Parameters:
        `E` - element type
      Parameters:
        `singleElement` - single element
      Returns:
        2dimensional read access with size 1 in both directions, containing just the given single element