de.caff.generics

## Interface MutableCharIndexable

- All Superinterfaces:
    CharIndexable, Copyable<MutableCharIndexable>, java.lang.Iterable<java.lang.Character>, PrimitiveCharIterable, Sizeable
  All Known Implementing Classes:
    MutableCharIndexable.Base

      public interface MutableCharIndexable
      extends CharIndexable, Copyable<MutableCharIndexable>

  Primitive char indexable with fixed length but mutable content. This may be used as a substitute for `char[]` as it eg allows read-only views or transparent views of subsets of the array.
  Since:
    November 01, 2019
  Author:
    Rammi

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `MutableCharIndexable.Base` Abstract base class which provides useful implementations for `Object.equals(Object)`, `Object.hashCode()`, `Object.toString()`.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static MutableCharIndexable.Base` | `EMPTY` Empty mutable indexable.

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

      `EMPTY_CHAR_ITERATOR`

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

      `NULL`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `default java.util.List<java.lang.Character>` | `asList()` View this indexable as a standard list.
    `static MutableCharIndexable.Base` | `based(MutableCharIndexable indexable)` View any mutable char indexable as a base char indexable.
    `static <IN> MutableCharIndexable.Base` | `copy(java.util.Collection<IN> collection, java.util.function.Function<IN,java.lang.Character> copier)` Create a mutable indexable which is initialized from copied elements of a given collection.
    `default void` | `copyInternally(int fromIndex, int toIndex, int numElements)` Copy elements inside this indexable.
    `static MutableCharIndexable.Base` | `copyOf(java.util.Collection<? extends java.lang.Character> collection)` Create a mutable indexable which is initialized from a given collection.
    `static MutableCharIndexable.Base` | `empty()`
    `default void` | `fillFrom(IntToCharFunction1 provider)` Fill this indexable from a provider.
    `static MutableCharIndexable.Base` | `fromArray(char... elements)` Create a mutable indexable which is initialized from elements of the given array.
    `static MutableCharIndexable.Base` | `fromArray(char[] elements, int startIndex, int length)` Create a mutable indexable which is initialized from elements of the given array.
    `static MutableCharIndexable.Base` | `fromCharIndexable(CharIndexable indexable)` Return a mutable char indexable initialized with the content of a standard char indexable.
    `static MutableCharIndexable.Base` | `fromIndexable(Indexable<? extends java.lang.Character> indexable)` Create a mutable indexable which is the copy of a standard indexable.
    `static <B> MutableCharIndexable.Base` | `fromIndexable(Indexable<B> indexable, java.util.function.Function<? super B,? extends java.lang.Character> converter)` Create a mutable indexable which is the copy of a standard indexable.
    `static MutableCharIndexable.Base` | `fromIterable(int size, java.lang.Iterable<? extends java.lang.Character> iter)` Create a mutable indexable from an iterable or a part of it.
    `default MutableCharIndexable` | `getCopy()` Get a copy of this object.
    `default MutableCharIndexable.Base` | `headSet(int toIndex)` Create an indexable subset from the last elements of this indexable set.
    `static MutableCharIndexable.Base` | `init(int size, char value)` Create a mutable
    `static MutableCharIndexable.Base` | `init(int size, java.util.function.Supplier<java.lang.Character> creator)` Initialize a mutable indexable to a given size.
    `static MutableCharIndexable.Base` | `initByIndex(int size, IntToCharFunction1 producer)` Get a mutable char indexable of a given size which contains elements created by index.
    `default void` | `initByIndex(IntToCharFunction1 setter)` Deprecated. use `fillFrom(IntToCharFunction1)` instead
    `default void` | `order()` Sort the elements in this indexable in their natural order.
    `default void` | `order(CharOrdering ordering)` Sort the elements in this indexable according to the given order.
    `default MutableCharIndexable.Base` | `reverse()` Get this indexable but with inverted order.
    `default void` | `revert()` Revert the elements in this indexable.
    `default void` | `revert(int from, int to)` Revert the order of all elements in the given range.
    `void` | `set(int index, char value)` Set the element at the given index.
    `default int` | `setFrom(java.lang.Iterable<? extends java.lang.Character> iterable)` Set the values of this mutable char indexable one after the other from the given Number iterable until either the iterable is emptied or `Sizeable.size()` elements are set.
    `default int` | `setFrom(java.lang.Iterable<? extends java.lang.Character> iterable, int startIndex, int numElements)` Set the values of this mutable char indexable one after the other from the given iterable until either the iterable is emptied or `numElements` elements are set.
    `default void` | `setFromArray(char[] array, int arrayIndex, int startIndex, int numElements)` Set consecutive entries from an array.
    `default void` | `setMulti(int from, int len, char value)` Set multiple elements to the same value.
    `default void` | `setRange(int startIndex, int length, char value)` Set a range to the same value.
    `default void` | `shuffle(java.util.Random random)` Randomize the content of this mutable indexable.
    `default MutableCharIndexable.Base` | `subSet(int fromIndex, int toIndex)` Get an indexable subset.
    `default void` | `swap(int idx1, int idx2)` Swap the values at two indices.
    `default void` | `swyp(int idx1, int idx2)` Swap the values at two indices using Pythonesque indices.
    `default MutableCharIndexable.Base` | `sybSet(int fromIndex, int toIndex)` Get an indexable subset.
    `default void` | `syt(int index, char value)` Pythonesque set.
    `default MutableCharIndexable.Base` | `tailSet(int fromIndex)` Create an indexable subset from the last elements of this indexable set.
    `default MutableIntIndexable.Base` | `toMutableIntIndexable()` Convert this mutable short array into an integer array.
    `static MutableCharIndexable.Base` | `viewArray(char[] array)` Mutable indexable view which operates on the given array.
    `static MutableCharIndexable.Base` | `viewArray(char[] array, int start, int length)` Mutable indexable view which operates on a part of the given array.
    `static <T> MutableCharIndexable.Base` | `viewIndexable(Indexable<T> indexable, ToCharFunction<? super T> getter, CharSetter<? super T> setter)` View a generic indexable as a mutable char indexable by accessing a char property of the elements of the underlying generic indexable.
    `static MutableCharIndexable.Base` | `viewList(java.util.List<java.lang.Character> list)` Mutable indexable view which operates on the given array.
    `static MutableCharIndexable.Base` | `zeroed(int size)` Create a mutable char indexable with `size` `(char)0)` elements.

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

      `addAllTo, addToArray, addToArray, addToArray, addToArray, asBase, asCharSequence, asCollection, asIndexable, asIntIndexable, binarySearch, binarySearch, charIterator, charIterator, compare, emptyIndexable, equal, equal, firstMatch, foldLeft, frozen, get, getMod, gyt, hash, indexes, intIndexes, intIterator, isEmpty, isOrdered, isOrdered, isStrictlyOrdered, isStrictlyOrdered, iterator, lastMatch, listIterator, makeString, nextMatch, ordered, previousMatch, rotated, singleton, toArray, toIntArray, toList, toString, toText, view, viewArray, viewAsBoolean, viewAsCharSequence, viewByIndex, viewChars, viewIndexable, viewIndexable, viewIndexable, viewList, viewList, viewList, viewOp, viewString, withAppendedValue, withExchangedValueAt, withInsertedValueAt, withRemovedValueAt, withSwappedValuesAt`

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

      `asIntIterable, asLongIterable, containsChar, forEachChar, forEachCharFragile`

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

      `forEach, spliterator`

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

      `size`

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

      `copy`

- - ### Field Detail

    - #### EMPTY

          static final MutableCharIndexable.Base EMPTY

      Empty mutable indexable. Use `empty()` instead.

  - ### Method Detail

    - #### set

          void set(int index,
                   char value)

      Set the element at the given index.
      Parameters:
        `index` - index between `0` and `size() - 1`
        `value` - value to put to the given index

    - #### syt

          default void syt(int index,
                           char value)

      Pythonesque set. This allows to access elements from the back by using negative indexes, e.g. `-1` references the last element, `-2` its predecessor, and so on.
      Parameters:
        `index` - index between `-size()` and `size() - 1`
        `value` - value to put to the given index

    - #### setRange

          default void setRange(int startIndex,
                                int length,
                                char value)

      Set a range to the same value.
      Parameters:
        `startIndex` - start index (Pythonesque)
        `length` - length (non-negative)
        `value` - value to set for the given range

    - #### setFrom

          default int setFrom(@NotNull
                              java.lang.Iterable<? extends java.lang.Character> iterable)

      Set the values of this mutable char indexable one after the other from the given Number iterable until either the iterable is emptied or `Sizeable.size()` elements are set.
      Parameters:
        `iterable` - iterable from which this indexable is filled
      Returns:
        number of elements set

    - #### setFrom

          default int setFrom(@NotNull
                              java.lang.Iterable<? extends java.lang.Character> iterable,
                              int startIndex,
                              int numElements)

      Set the values of this mutable char indexable one after the other from the given iterable until either the iterable is emptied or `numElements` elements are set.
      Parameters:
        `iterable` - iterable from which this indexable is filled
        `startIndex` - start index where the setting begins
        `numElements` - number of elements to set
      Returns:
        number of elements set

    - #### setFromArray

          default void setFromArray(@NotNull
                                    char[] array,
                                    int arrayIndex,
                                    int startIndex,
                                    int numElements)

      Set consecutive entries from an array. This will set less elements
      Parameters:
        `array` - array with elements to set from
        `arrayIndex` - start index in the array
        `startIndex` - start index in this mutable indexable
        `numElements` - number of elements to copy
      Throws:
        `java.lang.IndexOutOfBoundsException` - if this mutable indexable would overflow by this operation
        `java.lang.ArrayIndexOutOfBoundsException` - if array overflows by this operation

    - #### setMulti

          default void setMulti(int from,
                                int len,
                                char value)

      Set multiple elements to the same value.
      Parameters:
        `from` - first index to be set (Pythonesque)
        `len` - number of elements to be set (non-negative)
        `value` - value to be set

    - #### copyInternally

          default void copyInternally(int fromIndex,
                                      int toIndex,
                                      int numElements)

      Copy elements inside this indexable.
      Parameters:
        `fromIndex` - start index from where elements are copied (Pythonesque)
        `toIndex` - start index to where elements are copied (Pythonesque)
        `numElements` - number of elements to copy

    - #### fillFrom

          default void fillFrom(@NotNull
                                IntToCharFunction1 provider)

      Fill this indexable from a provider.
      Parameters:
        `provider` - provider which is called for each index and provides the element for that index

    - #### swap

          default void swap(int idx1,
                            int idx2)

      Swap the values at two indices.
      Parameters:
        `idx1` - first index
        `idx2` - second index

    - #### swyp

          default void swyp(int idx1,
                            int idx2)

      Swap the values at two indices using Pythonesque indices.
      Parameters:
        `idx1` - first index (`Pythonesque`)
        `idx2` - second index (`Pythonesque`)

    - #### subSet

          @NotNull
          default MutableCharIndexable.Base subSet(int fromIndex,
                                                            int toIndex)

      Description copied from interface: `CharIndexable`
      Get an indexable subset. The subset includes indices `fromIndex` to `toIndex - 1`.
      Specified by:
        `subSet` in interface `CharIndexable`
      Parameters:
        `fromIndex` - start index of sub set
        `toIndex` - index after last index
      Returns:
        indxable subset view of this indexable

    - #### sybSet

          @NotNull
          default MutableCharIndexable.Base sybSet(int fromIndex,
                                                            int toIndex)

      Description copied from interface: `CharIndexable`
      Get an indexable subset. This is the Pythonesque version which allows negative indexes.
      Specified by:
        `sybSet` in interface `CharIndexable`
      Parameters:
        `fromIndex` - start index of sub set
        `toIndex` - end index of sub set
      Returns:
        indexable subset view of this indexable set

    - #### tailSet

          @NotNull
          default MutableCharIndexable.Base tailSet(int fromIndex)

      Description copied from interface: `CharIndexable`
      Create an indexable subset from the last elements of this indexable set. This already allows Pythonesquew indexing.
      Specified by:
        `tailSet` in interface `CharIndexable`
      Parameters:
        `fromIndex` - index to start with, negative counts from the back
      Returns:
        indexable subset view of this indexable set

    - #### headSet

          @NotNull
          default MutableCharIndexable.Base headSet(int toIndex)

      Description copied from interface: `CharIndexable`
      Create an indexable subset from the last elements of this indexable set. This already allows Pythonesquew indexing.
      Specified by:
        `headSet` in interface `CharIndexable`
      Parameters:
        `toIndex` - index one after the end (equal to the length of the returned set), negative counts from the back
      Returns:
        indexable subset view of this indexable set

    - #### reverse

          @NotNull
          default MutableCharIndexable.Base reverse()

      Description copied from interface: `CharIndexable`
      Get this indexable but with inverted order.
      Specified by:
        `reverse` in interface `CharIndexable`
      Returns:
        a view to this indexable which accesses the elements in reverse order

    - #### revert

          default void revert(int from,
                              int to)

      Revert the order of all elements in the given range. Attention: the `to` element is also included in the reversion to allow easy reversion at the end by using `-1`.
      Parameters:
        `from` - start element of reversion (Pythonesque), included
        `to` - end element of reversion (Pythonesque), included

    - #### revert

          default void revert()

      Revert the elements in this indexable. This reverts the order of all elements.

    - #### order

          default void order()

      Sort the elements in this indexable in their natural order.

    - #### order

          default void order(@NotNull
                             CharOrdering ordering)

      Sort the elements in this indexable according to the given order.
      Parameters:
        `ordering` - sort order

    - #### shuffle

          default void shuffle(@NotNull
                               java.util.Random random)

      Randomize the content of this mutable indexable. This will reorder the elements randomly.
      Parameters:
        `random` - random number generator

    - #### initByIndex

          @Deprecated
          default void initByIndex(@NotNull
                                               IntToCharFunction1 setter)

      Deprecated. use `fillFrom(IntToCharFunction1)` instead
      Set all values of this char indexable by index.
      Parameters:
        `setter` - setter which provides the value to be set for a given index

    - #### asList

          @NotNull
          default java.util.List<java.lang.Character> asList()

      View this indexable as a standard list. Overwritten to allow for modifications. The returned list will allow usage of the `List.set(int, Object)` method, but neither any adding nor deleting methods. Standard sorting algorithms will work on the returned list as a sorting algorithm is expected to neither move nor add elements.
      Specified by:
        `asList` in interface `CharIndexable`
      Returns:
        list allowing setting elements
      See Also:
        `CharIndexable.toList()`

    - #### getCopy

          @NotNull
          default MutableCharIndexable getCopy()

      Description copied from interface: `Copyable`
      Get a copy of this object. Immutable objects are allowed to return themselves. The copy needs not to be of the same class, it just has to fulfill the type restriction.
      Specified by:
        `getCopy` in interface `Copyable<MutableCharIndexable>`
      Returns:
        independent copy of this object

    - #### based

          @NotNull
          static MutableCharIndexable.Base based(@NotNull
                                                          MutableCharIndexable indexable)

      View any mutable char indexable as a base char indexable. The latter provides various standard methods for comparison, output and hanshing.
      Parameters:
        `indexable` - mutqable char indexable to view as a `MutableCharIndexable.Base` mutable char indexable
      Returns:
        base view of given indexable, or the indexable itself if it is already a Base

    - #### init

          @NotNull
          static MutableCharIndexable.Base init(int size,
                                                         @NotNull
                                                         java.util.function.Supplier<java.lang.Character> creator)

      Initialize a mutable indexable to a given size.
      Parameters:
        `size` - size of indexable
        `creator` - creator for the initial eleeents
      Returns:
        mutable indexable with the given size
      See Also:
        `init(int, char)`, `zeroed(int)`

    - #### initByIndex

          @NotNull
          static MutableCharIndexable.Base initByIndex(int size,
                                                                @NotNull
                                                                IntToCharFunction1 producer)

      Get a mutable char indexable of a given size which contains elements created by index.
      Specified by:
        `initByIndex` in interface `CharIndexable`
      Parameters:
        `size` - size of the returned indexable
        `producer` - producer which is called with an index and expected to return the associated value
      Returns:
        a mutable char indexable with the given size with elements initialized by calling the `producer`
      See Also:
        `CharIndexable.viewByIndex(int, IntToCharFunction1)`

    - #### copyOf

          @NotNull
          static MutableCharIndexable.Base copyOf(@NotNull
                                                           java.util.Collection<? extends java.lang.Character> collection)

      Create a mutable indexable which is initialized from a given collection.
      Parameters:
        `collection` - collection
      Returns:
        mutable indexable

    - #### copy

          @NotNull
          static <IN> MutableCharIndexable.Base copy(@NotNull
                                                              java.util.Collection<IN> collection,
                                                              @NotNull
                                                              java.util.function.Function<IN,java.lang.Character> copier)

      Create a mutable indexable which is initialized from copied elements of a given collection.
      Type Parameters:
        `IN` - incoming element type
      Parameters:
        `collection` - collection
        `copier` - element copier
      Returns:
        mutable indexable

    - #### empty

          @NotNull
          static MutableCharIndexable.Base empty()

    - #### fromArray

          @NotNull
          static MutableCharIndexable.Base fromArray(@NotNull
                                                              char... elements)

      Create a mutable indexable which is initialized from elements of the given array.
      Parameters:
        `elements` - elements
      Returns:
        mutable indexable independent of `elements`

    - #### fromArray

          @NotNull
          static MutableCharIndexable.Base fromArray(@NotNull
                                                              char[] elements,
                                                              int startIndex,
                                                              int length)

      Create a mutable indexable which is initialized from elements of the given array.
      Parameters:
        `elements` - array of elements
        `startIndex` - index of first element used in the returned indxable
        `length` - length number of elements used in the returned indexable
      Returns:
        mutable indexable independnet of `eleements`

    - #### viewArray

          @NotNull
          static MutableCharIndexable.Base viewArray(@NotNull
                                                              char[] array)

      Mutable indexable view which operates on the given array. Any changes done by the returned indexable will be forwarded to the array.
      Specified by:
        `viewArray` in interface `CharIndexable`
      Parameters:
        `array` - array
      Returns:
        mutable indexable view of the given array

    - #### viewArray

          @NotNull
          static MutableCharIndexable.Base viewArray(@NotNull
                                                              char[] array,
                                                              int start,
                                                              int length)

      Mutable indexable view which operates on a part of the given array.
      Specified by:
        `viewArray` in interface `CharIndexable`
      Parameters:
        `array` - array
        `start` - start position in array
        `length` - length of returned indexable
      Returns:
        mutable char indexable view of the given part of the array

    - #### toMutableIntIndexable

          @NotNull
          default MutableIntIndexable.Base toMutableIntIndexable()

      Convert this mutable short array into an integer array.

      It is recommended to do this when this indexable is heavily used.

      Returns:
        mutable int indexable copy of this short indexable

    - #### viewList

          @NotNull
          static MutableCharIndexable.Base viewList(@NotNull
                                                             java.util.List<java.lang.Character> list)

      Mutable indexable view which operates on the given array. Any changes done by the returned indexable will be forwarded to the list.
      Parameters:
        `list` - list
      Returns:
        mutable indexable view of the given list

    - #### fromIndexable

          @NotNull
          static MutableCharIndexable.Base fromIndexable(@NotNull
                                                                  Indexable<? extends java.lang.Character> indexable)

      Create a mutable indexable which is the copy of a standard indexable.
      Parameters:
        `indexable` - standard indexable
      Returns:
        mutable indexable initialize from the standard indexable

    - #### fromIndexable

          @NotNull
          static <B> MutableCharIndexable.Base fromIndexable(@NotNull
                                                                      Indexable<B> indexable,
                                                                      @NotNull
                                                                      java.util.function.Function<? super B,? extends java.lang.Character> converter)

      Create a mutable indexable which is the copy of a standard indexable. This especieally allows to copy each element during the initialization.
      Type Parameters:
        `B` - element type of incoming idexable
      Parameters:
        `indexable` - base indexable
        `converter` - converter from base indexable type to result element type,
      Returns:
        mutable indexable

    - #### fromCharIndexable

          @NotNull
          static MutableCharIndexable.Base fromCharIndexable(@NotNull
                                                                      CharIndexable indexable)

      Return a mutable char indexable initialized with the content of a standard char indexable.
      Parameters:
        `indexable` - char indexable
      Returns:
        mutable indexable initialized with the values of the given char indexable

    - #### viewIndexable

          @NotNull
          static <T> MutableCharIndexable.Base viewIndexable(@NotNull
                                                                      Indexable<T> indexable,
                                                                      @NotNull
                                                                      ToCharFunction<? super T> getter,
                                                                      @NotNull
                                                                      CharSetter<? super T> setter)

      View a generic indexable as a mutable char indexable by accessing a char property of the elements of the underlying generic indexable.

      This is useful if you have complex items, but are interested into only one (char) property of each item.

      Type Parameters:
        `T` - element type of the underlying indexable
      Parameters:
        `indexable` - underlying generic indexable
        `getter` - function used to extract the property of interest
        `setter` - procedure used to set the property of interest
      Returns:
        mutable char indexable view of the underlying indexable

    - #### fromIterable

          @NotNull
          static MutableCharIndexable.Base fromIterable(int size,
                                                                 @NotNull
                                                                 java.lang.Iterable<? extends java.lang.Character> iter)

      Create a mutable indexable from an iterable or a part of it.
      Parameters:
        `size` - maximum size of returned indexable
        `iter` - iterable used for initializing the indexable
      Returns:
        mutable indexable

    - #### zeroed

          @NotNull
          static MutableCharIndexable.Base zeroed(int size)

      Create a mutable char indexable with `size` `(char)0)` elements.
      Parameters:
        `size` - required size of returned mutable char indexable
      Returns:
        mutable char indexable of the given size initialized with `(char)0)`
      See Also:
        `init(int, char)`, `init(int, Supplier)`

    - #### init

          @NotNull
          static MutableCharIndexable.Base init(int size,
                                                         char value)

      Create a mutable
      Specified by:
        `init` in interface `CharIndexable`
      Parameters:
        `size` - required size of returned mutable char indexable
        `value` - initial value of all elements
      Returns:
        mutable char indexable of the given size initialized with `value`
      See Also:
        `init(int, Supplier)`, `zeroed(int)`