de.caff.generics

## Class UnmodifiableListFloatArrayWrapper

- java.lang.Object
- - de.caff.generics.AbstractBasicUnmodifiableList<java.lang.Float>
  - - de.caff.generics.UnmodifiableListFloatArrayWrapper

- All Implemented Interfaces:
    java.lang.Iterable<java.lang.Float>, java.util.Collection<java.lang.Float>, java.util.List<java.lang.Float>

      public class UnmodifiableListFloatArrayWrapper
      extends AbstractBasicUnmodifiableList<java.lang.Float>

  Let an array appear as an unmodifiable list.

  This is cheaper than `java.util.Arrays.asList()` and allows for sub arrays to be accessed.

  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UnmodifiableListFloatArrayWrapper(float[] array)` Constructor.
    `UnmodifiableListFloatArrayWrapper(float[] array, int length)` Constructor.
    `UnmodifiableListFloatArrayWrapper(float[] array, int start, int length)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `contains(java.lang.Object o)` Returns `true` if this list contains the specified element.
    `boolean` | `containsAll(java.util.Collection c)` Returns `true` if this list contains all of the elements of the specified collection.
    `java.lang.Float` | `get(int index)` Returns the element at the specified position in this list.
    `int` | `indexOf(java.lang.Object o)` Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
    `boolean` | `isEmpty()` Returns `true` if this list contains no elements.
    `java.util.Iterator<java.lang.Float>` | `iterator()` Returns an iterator over the elements in this list in proper sequence.
    `int` | `lastIndexOf(java.lang.Object o)` Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
    `java.util.ListIterator<java.lang.Float>` | `listIterator()` Returns a list iterator of the elements in this list (in proper sequence).
    `java.util.ListIterator<java.lang.Float>` | `listIterator(int index)` Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
    `int` | `size()` Returns the number of elements in this list.
    `java.util.List<java.lang.Float>` | `subList(int fromIndex, int toIndex)` Returns a view of the portion of this list between the specified `fromIndex`, inclusive, and `toIndex`, exclusive.
    `java.lang.Object[]` | `toArray()` Returns an array containing all of the elements in this list in proper sequence.
    `<S> S[]` | `toArray(S[] a)` Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array.

    - ### Methods inherited from class de.caff.generics.AbstractBasicUnmodifiableList

      `add, add, addAll, addAll, clear, remove, remove, removeAll, retainAll, set`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.List

      `equals, hashCode, replaceAll, sort, spliterator`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

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

      `forEach`

- - ### Constructor Detail

    - #### UnmodifiableListFloatArrayWrapper

          public UnmodifiableListFloatArrayWrapper(@NotNull
                                                   float[] array,
                                                   int start,
                                                   int length)

      Constructor.
      Parameters:
        `array` - array to wrap
        `start` - start index to use
        `length` - length to use

    - #### UnmodifiableListFloatArrayWrapper

          public UnmodifiableListFloatArrayWrapper(@NotNull
                                                   float[] array)

      Constructor. This uses the complete array.
      Parameters:
        `array` - array to wrap

    - #### UnmodifiableListFloatArrayWrapper

          public UnmodifiableListFloatArrayWrapper(@NotNull
                                                   float[] array,
                                                   int length)

      Constructor. This uses only length elements of the complete array, starting with the zeroth element..
      Parameters:
        `array` - array to wrap
        `length` - length to use

  - ### Method Detail

    - #### size

          public int size()

      Returns the number of elements in this list. If this list contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.
      Returns:
        the number of elements in this list.

    - #### isEmpty

          public boolean isEmpty()

      Returns `true` if this list contains no elements.
      Returns:
        `true` if this list contains no elements.

    - #### toArray

          @NotNull
          public java.lang.Object[] toArray()

      Returns an array containing all of the elements in this list in proper sequence. Obeys the general contract of the `Collection.toArray` method.
      Returns:
        an array containing all of the elements in this list in proper sequence.
      See Also:
        `Arrays.asList(Object[])`

    - #### get

          public java.lang.Float get(int index)

      Returns the element at the specified position in this list.
      Parameters:
        `index` - index of element to return.
      Returns:
        the element at the specified position in this list.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index >= size()).

    - #### indexOf

          public int indexOf(java.lang.Object o)

      Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the lowest index `i` such that `(o==null ? get(i)==null : o.equals(get(i)))`, or -1 if there is no such index.
      Parameters:
        `o` - element to search for.
      Returns:
        the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
      Throws:
        `java.lang.ClassCastException` - if the type of the specified element is incompatible with this list (optional).
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements (optional).

    - #### lastIndexOf

          public int lastIndexOf(java.lang.Object o)

      Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. More formally, returns the highest index `i` such that `(o==null ? get(i)==null : o.equals(get(i)))`, or -1 if there is no such index.
      Parameters:
        `o` - element to search for.
      Returns:
        the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
      Throws:
        `java.lang.ClassCastException` - if the type of the specified element is incompatible with this list (optional).
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements (optional).

    - #### contains

          public boolean contains(java.lang.Object o)

      Returns `true` if this list contains the specified element. More formally, returns `true` if and only if this list contains at least one element `e` such that `(o==null ? e==null : o.equals(e))`.
      Parameters:
        `o` - element whose presence in this list is to be tested.
      Returns:
        `true` if this list contains the specified element.
      Throws:
        `java.lang.ClassCastException` - if the type of the specified element is incompatible with this list (optional).
        `java.lang.NullPointerException` - if the specified element is null and this list does not support null elements (optional).

    - #### containsAll

          public boolean containsAll(@NotNull
                                     java.util.Collection c)

      Returns `true` if this list contains all of the elements of the specified collection.
      Parameters:
        `c` - collection to be checked for containment in this list.
      Returns:
        `true` if this list contains all of the elements of the specified collection.
      Throws:
        `java.lang.ClassCastException` - if the types of one or more elements in the specified collection are incompatible with this list (optional).
        `java.lang.NullPointerException` - if the specified collection contains one or more null elements and this list does not support null elements (optional). or if the specified collection is `null`.
      See Also:
        `contains(Object)`

    - #### iterator

          @NotNull
          public java.util.Iterator<java.lang.Float> iterator()

      Returns an iterator over the elements in this list in proper sequence.
      Returns:
        an iterator over the elements in this list in proper sequence.

    - #### subList

          @NotNull
          public java.util.List<java.lang.Float> subList(int fromIndex,
                                                                  int toIndex)

      Returns a view of the portion of this list between the specified `fromIndex`, inclusive, and `toIndex`, exclusive. (If `fromIndex` and `toIndex` are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

      This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

                      list.subList(from, to).clear();

      Similar idioms may be constructed for `indexOf` and `lastIndexOf`, and all of the algorithms in the `Collections` class can be applied to a subList.

      The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

      Parameters:
        `fromIndex` - low endpoint (inclusive) of the subList.
        `toIndex` - high endpoint (exclusive) of the subList.
      Returns:
        a view of the specified range within this list.
      Throws:
        `java.lang.IndexOutOfBoundsException` - for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex).

    - #### listIterator

          @NotNull
          public java.util.ListIterator<java.lang.Float> listIterator()

      Returns a list iterator of the elements in this list (in proper sequence).
      Returns:
        a list iterator of the elements in this list (in proper sequence).

    - #### listIterator

          @NotNull
          public java.util.ListIterator<java.lang.Float> listIterator(int index)

      Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to the `next` method. An initial call to the `previous` method would return the element with the specified index minus one.
      Parameters:
        `index` - index of first element to be returned from the list iterator (by a call to the `next` method).
      Returns:
        a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (index < 0 || index > size()).

    - #### toArray

          @NotNull
          public <S> S[] toArray(@NotNull
                                          S[] a)

      Returns an array containing all of the elements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of the `Collection.toArray(Object[])` method.
      Parameters:
        `a` - the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
      Returns:
        an array containing the elements of this list.
      Throws:
        `java.lang.ArrayStoreException` - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list.
        `java.lang.NullPointerException` - if the specified array is `null`.