de.caff.generics

## Interface ExpandableLongIndexable

- All Superinterfaces:
    java.lang.Iterable<java.lang.Long>, LongIndexable, PrimitiveLongIterable, Sizeable

      public interface ExpandableLongIndexable
      extends LongIndexable

  Immutable expandable primitive long indexable.

  This interface defines a long 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(long...)`
  - `from(long[], int, int)`
  - `from(LongIndexable)`
  - `from(Indexable)`
  - `from(Collection)`
  - `fromNumbers(Number[])`
  Since:
    September 24, 2020
  Author:
    Rammi

- - ### Nested Class Summary

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

      `LongIndexable.Base, LongIndexable.LongIndexableSpliterator`

  - ### Field Summary

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

      `EMPTY`

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

      `EMPTY_LONG_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
    --- | ---
    `ExpandableLongIndexable` | `add(int index, long value)` Return an exoandable long indexable Insert where the the given value was inserted at the given index.
    `default ExpandableLongIndexable` | `add(long value)` Return an expandable long indexable where the given value was added to the end of this indexable.
    `static ExpandableLongIndexable` | `empty()` Convenience method to create an empty expandable int indexable.
    `static ExpandableLongIndexable` | `from(java.util.Collection<? extends java.lang.Number> values)` Create an expandable integer indexable from a collection of numbers.
    `static ExpandableLongIndexable` | `from(Indexable<? extends java.lang.Number> indexable)` Get an expandable integer indexable from an indexable of numbers.
    `static ExpandableLongIndexable` | `from(long... values)` Create an expandable integer indexable from an initial array of values.
    `static ExpandableLongIndexable` | `from(long[] array, int start, int length)` Create an expandable integer indexable from part of an int array.
    `static ExpandableLongIndexable` | `from(LongIndexable indexable)` Get an expandable integer indexable from a normal integer indexable.
    `static <N extends java.lang.Number> ExpandableLongIndexable` | `fromNumbers(N... values)` Get an expandable integer indexable from an array of numbers.
    `ExpandableLongIndexable` | `getCopy()` Get an expandable copy of this long indexable.
    `static LongIndexable` | `initByIndex(int size, java.util.function.IntToLongFunction producer)` Create an expandable long indexable with a given size, and initialize its elements by index.
    `ExpandableLongIndexable` | `remove(int index)` Return an expandable long indexable where the value at the given index was removed.
    `default ExpandableLongIndexable` | `remyve(int index)` Pythonesque remove allowing negative indexes to remove from the end.
    `default ExpandableLongIndexable` | `ydd(int index, long value)` Pythonesque insertion allowing negative indexes to insert from the end.
    `static ExpandableLongIndexable` | `zeroed(int size)` Create an expandable int indexable of the given size initialized with `0.0`.

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

      `addAllTo, addToArray, addToArray, asBase, asCollection, asIndexable, asList, binarySearch, binarySearch, compare, compareUnsigned, emptyIndexable, equal, equal, firstMatch, foldLeft, frozen, frozenLongSpliterator, get, getMod, gyt, hash, headSet, indexes, init, intIndexes, isEmpty, isOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, longIterator, longIterator, longSpliterator, nextMatch, ordered, ordered, previousMatch, reverse, rotated, singleton, subSet, sybSet, tailSet, toArray, toList, toString, view, viewArray, viewArray, viewArray, viewAsBoolean, viewAsByte, viewAsDouble, viewAsDouble, viewAsFloat, viewAsInt, viewAsInt, viewAsShort, viewByIndex, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewNumberArray, viewOp, withAppendedValue, withCachedHash, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt`

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

      `average, containsLong, forEachLong, forEachLongFragile, 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
          ExpandableLongIndexable add(int index,
                                               long value)

      Return an exoandable long 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 long indexable with the given value inserted

    - #### remove

          @NotNull
          ExpandableLongIndexable remove(int index)

      Return an expandable long 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 long indexable with the given index removed

    - #### getCopy

          @NotNull
          ExpandableLongIndexable getCopy()

      Get an expandable copy of this long indexable. As this is basically immutable extending classes are expected to return `this`.
      Returns:
        independent copy of this indexable

    - #### add

          @NotNull
          default ExpandableLongIndexable add(long value)

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

    - #### ydd

          @NotNull
          default ExpandableLongIndexable ydd(int index,
                                                       long value)

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

    - #### remyve

          @NotNull
          default ExpandableLongIndexable 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 long indexable with the given index removed

    - #### empty

          @NotNull
          static ExpandableLongIndexable empty()

      Convenience method to create an empty expandable int indexable.
      Returns:
        empty expandable int indexable

    - #### zeroed

          @NotNull
          static ExpandableLongIndexable zeroed(int size)

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

    - #### initByIndex

          @NotNull
          static LongIndexable initByIndex(int size,
                                                    @NotNull
                                                    java.util.function.IntToLongFunction producer)

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

    - #### from

          @NotNull
          static ExpandableLongIndexable from(@NotNull
                                                       long... values)

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

    - #### from

          @NotNull
          static ExpandableLongIndexable from(@NotNull
                                                       long[] 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 ExpandableLongIndexable from(@NotNull
                                                       LongIndexable 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> ExpandableLongIndexable 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 ExpandableLongIndexable 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 ExpandableLongIndexable 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