de.caff.generics

## Interface ExpandableIntIndexable

- All Superinterfaces:
    IntCountable, IntIndexable, java.lang.Iterable<java.lang.Integer>, PrimitiveIntIterable, Sizeable

      public interface ExpandableIntIndexable
      extends IntIndexable

  Immutable expandable primitive integer indexable.

  This interface defines an integer indexable which allows to change (set, add, remove) its values but is immutable nevertheless. All changing methods return copies, thus guaranteeing immutability.

  The internal implementation tries to keep copying a cheap operation, but some access patterns may result in performance degration. It is therefore recommended not to use this in time-critical code.

  Initial creation is done by using the following methods:

  - `empty()`
  - `zeroed(int)`
  - `from(int...)`
  - `from(int[], int, int)`
  - `from(IntIndexable)`
  - `from(Indexable)`
  - `from(Collection)`
  - `fromNumbers(Number[])`
  Since:
    September 24, 2020
  Author:
    Rammi

- - ### Nested Class Summary

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

      `IntIndexable.Base, IntIndexable.EntryConsumer, IntIndexable.IntIndexableSpliterator`

  - ### Field Summary

    - ### Fields inherited from interface de.caff.generics.IntIndexable

      `EMPTY, SINGLE_0`

    - ### Fields inherited from interface de.caff.generics.PrimitiveIntIterable

      `EMPTY_INT_ITERATOR`

    - ### Fields inherited from interface de.caff.generics.Sizeable

      `NULL`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default ExpandableIntIndexable` | `add(int value)` Return an expandable int indexable where the given value was added to the end of this indexable.
    `ExpandableIntIndexable` | `add(int index, int value)` Return an expandable int indexable Insert where the the given value was inserted at the given index.
    `default ExpandableIntIndexable` | `addAll(int... values)` Add all values.
    `static ExpandableIntIndexable` | `empty()` Convenience method to create an empty expandable int indexable.
    `static ExpandableIntIndexable` | `from(java.util.Collection<? extends java.lang.Number> values)` Create an expandable integer indexable from a collection of numbers.
    `static ExpandableIntIndexable` | `from(Indexable<? extends java.lang.Number> indexable)` Get an expandable integer indexable from an indexable of numbers.
    `static ExpandableIntIndexable` | `from(int... values)` Create an expandable integer indexable from an initial array of values.
    `static ExpandableIntIndexable` | `from(int[] array, int start, int length)` Create an expandable integer indexable from part of an int array.
    `static ExpandableIntIndexable` | `from(IntIndexable indexable)` Get an expandable integer indexable from a normal integer indexable.
    `static <N extends java.lang.Number> ExpandableIntIndexable` | `fromNumbers(N... values)` Get an expandable integer indexable from an array of numbers.
    `static IntIndexable` | `initByIndex(int size, java.util.function.IntUnaryOperator producer)` Create an expandable int indexable with a given size, and initialize its elements by index.
    `ExpandableIntIndexable` | `remove(int index)` Return an expandable int indexable where the value at the given index was removed.
    `default ExpandableIntIndexable` | `remyve(int index)` Pythonesque remove allowing negative indexes to remove from the end.
    `default ExpandableIntIndexable` | `ydd(int index, int value)` Pythonesque insertion allowing negative indexes to insert from the end.
    `static ExpandableIntIndexable` | `zeroed(int size)` Create an expandable int indexable of the given size initialized with `0`.

    - ### Methods inherited from interface de.caff.generics.IntIndexable

      `addAllTo, addToArray, addToArray, asBase, asCollection, asIndexable, asList, asLongIndexable, asUnsignedIndexable, binarySearch, binarySearch, compare, compareUnsigned, emptyIndexable, equal, equal, firstMatch, foldLeft, forEachIntEntry, frozen, frozenIntSpliterator, get, getMod, gyt, hash, headSet, indexes, init, intIndexes, intIterator, intIterator, intSpliterator, isEmpty, isOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, nextMatch, ordered, ordered, previousMatch, range, range, rangeFromSize, reverse, rotated, singleton, subSet, sybSet, tailSet, toArray, toList, toString, view, viewArray, viewArray, viewArray, viewAsBoolean, viewAsByte, viewAsChar, viewAsDouble, viewAsDouble, viewAsFloat, viewAsLong, viewAsLong, viewAsShort, viewAsUnsignedLong, viewByIndex, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewNumberArray, viewOp, with, withAppendedValue, withCachedHash, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt, wyth`

    - ### Methods inherited from interface de.caff.generics.IntCountable

      `filtered, first, isEqual, isSorted, isStrictlySorted, last, sorted, toString, uniform, viewCollection, viewCollection, viewCollectionN, viewCollectionN`

    - ### Methods inherited from interface de.caff.generics.PrimitiveIntIterable

      `average, containsInt, forEachInt, forEachIntFragile, longSum, longSumX, spliterator, stream, sum, sumX`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### Methods inherited from interface de.caff.generics.Sizeable

      `size`

- - ### Method Detail

    - #### add

          @NotNull
          ExpandableIntIndexable add(int index,
                                              int value)

      Return an expandable int indexable Insert where the the given value was inserted at the given index.
      Parameters:
        `index` - index in the range `0` (insert at first position) to `size()` (insert after last position)
        `value` - value to insert at the given position
      Returns:
        new integer indexable with the given value inserted

    - #### remove

          @NotNull
          ExpandableIntIndexable remove(int index)

      Return an expandable int indexable where the value at the given index was removed.
      Parameters:
        `index` - index to remove, in the range `0` to `size() - 1`
      Returns:
        new expandable integer indexable with the given index removed

    - #### add

          @NotNull
          default ExpandableIntIndexable add(int value)

      Return an expandable int indexable where the given value was added to the end of this indexable.
      Parameters:
        `value` - value to add
      Returns:
        new integer indexable with added value

    - #### addAll

          @NotNull
          default ExpandableIntIndexable addAll(@NotNull
                                                         int... values)

      Add all values.
      Parameters:
        `values` - values to add
      Returns:
        expandable int indexable where all the values are added

    - #### ydd

          @NotNull
          default ExpandableIntIndexable ydd(int index,
                                                      int value)

      Pythonesque insertion allowing negative indexes to insert from the end.
      Parameters:
        `index` - positive values behave the same way as `add(int, int)`, but negative values count from the back, so `-1` will insert before the last element
        `value` - value to insert
      Returns:
        new integer indexable with the given value inserted

    - #### remyve

          @NotNull
          default ExpandableIntIndexable remyve(int index)

      Pythonesque remove allowing negative indexes to remove from the end.
      Parameters:
        `index` - positive values behave the same as `remove(int)`, while negative indexes count from the back, so `-1` will remove the last element
      Returns:
        new expandable integer indexable with the given index removed

    - #### empty

          @NotNull
          static ExpandableIntIndexable empty()

      Convenience method to create an empty expandable int indexable.
      Specified by:
        `empty` in interface `IntCountable`
      Returns:
        empty expandable int indexable

    - #### zeroed

          @NotNull
          static ExpandableIntIndexable zeroed(int size)

      Create an expandable int indexable of the given size initialized with `0`.
      Parameters:
        `size` - size of returned integer indexable
      Returns:
        expandable integer indexable of the given size

    - #### initByIndex

          @NotNull
          static IntIndexable initByIndex(int size,
                                                   @NotNull
                                                   java.util.function.IntUnaryOperator producer)

      Create an expandable int indexable with a given size, and initialize its elements by index.
      Specified by:
        `initByIndex` in interface `IntIndexable`
      Parameters:
        `size` - size of the indexable
        `producer` - element producer which will be called for each index
      Returns:
        expandable int indexable with the given size containing the elements created by the producer
      See Also:
        `IntIndexable.viewByIndex(int, IntUnaryOperator)`

    - #### from

          @NotNull
          static ExpandableIntIndexable from(@NotNull
                                                      int... values)

      Create an expandable integer indexable from an initial array of values.
      Parameters:
        `values` - array of values
      Returns:
        expandable integer indexable

    - #### from

          @NotNull
          static ExpandableIntIndexable from(@NotNull
                                                      int[] array,
                                                      int start,
                                                      int length)

      Create an expandable integer indexable from part of an int array.
      Parameters:
        `array` - integer array
        `start` - start position in array
        `length` - number of byte in array
      Returns:
        expandable integer indexable

    - #### from

          @NotNull
          static ExpandableIntIndexable from(@NotNull
                                                      IntIndexable indexable)

      Get an expandable integer indexable from a normal integer indexable.
      Parameters:
        `indexable` - standard integer indexable
      Returns:
        expandable copy of the given indexable

    - #### fromNumbers

          @NotNull
           @SafeVarargs
          static <N extends java.lang.Number> ExpandableIntIndexable fromNumbers(@NotNull
                                                                                                        N... values)

      Get an expandable integer indexable from an array of numbers.
      Type Parameters:
        `N` - number type, prefarably `Integer`
      Parameters:
        `values` - number values
      Returns:
        expandable int indexable

    - #### from

          @NotNull
          static ExpandableIntIndexable from(@NotNull
                                                      Indexable<? extends java.lang.Number> indexable)

      Get an expandable integer indexable from an indexable of numbers.
      Parameters:
        `indexable` - numbers indexable
      Returns:
        expandable int indexable

    - #### from

          @NotNull
          static ExpandableIntIndexable from(@NotNull
                                                      java.util.Collection<? extends java.lang.Number> values)

      Create an expandable integer indexable from a collection of numbers.
      Parameters:
        `values` - collection of numbers, `List` is strongly recommended for better performance
      Returns:
        expandable integer indexable