Class ArrayVector.UnsignedIntegers

All Implemented Interfaces:
Serializable, Iterable<Number>, Collection<Number>, List<Number>, RandomAccess, SequencedCollection<Number>, CheckedContainer<Integer>
Enclosing class:
ArrayVector<E extends Number>

private static final class ArrayVector.UnsignedIntegers extends ArrayVector.Integers
A vector backed by an array of type int[] to be interpreted as unsigned values.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
  • Constructor Details

    • UnsignedIntegers

      UnsignedIntegers(int[] array)
      Creates a new vector for the given array.
  • Method Details

    • isUnsigned

      public boolean isUnsigned()
      Declares this vector as unsigned.
      Overrides:
      isUnsigned in class Vector
      Returns:
      true if the integer values shall be interpreted as unsigned values.
    • doubleValue

      public double doubleValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a double. This is the safest method since all primitive types supported by Vector are convertible to the double type.
      Overrides:
      doubleValue in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
      See Also:
    • floatValue

      public float floatValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a float. This method may result in a lost of precision if this vector stores or computes its values with the double type.

      The default implementation delegates to Vector.doubleValue(int) and cast the result to float.

      Overrides:
      floatValue in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
      See Also:
    • longValue

      public long longValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as a long. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.doubleValue(int) and verifies if the result can be rounded to a long with an error not greater than 0.5. Subclasses that store or compute their values with an integer type should override this method.

      Overrides:
      longValue in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • intValue

      public int intValue(int index)
      Description copied from class: Vector
      Returns the value at the given index as an int. If this vector uses floating point values, the value is rounded to the nearest integer.

      The default implementation delegates to Vector.longValue(int) and verifies if the result fits in the int type. Subclasses that store or compute their values with the int, short or byte type should override this method.

      Overrides:
      intValue in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
    • get

      public Number get(int index)
      Unconditionally uses a larger type since the value may exceed integer capacity.
      Specified by:
      get in interface List<Number>
      Overrides:
      get in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index (may be null).
    • verifyType

      void verifyType(Number value, byte expected)
      Verifies that the given value can be stored as an unsigned integer.
      Overrides:
      verifyType in class ArrayVector<Integer>
    • stringValue

      public String stringValue(int index)
      Returns the string representation at the given index.
      Overrides:
      stringValue in class ArrayVector.Integers
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      a string representation of the value at the given index (may be null).
      See Also:
    • range

      NumberRange<?> range(IntSupplier indices, int n)
      Finds the minimum and maximum values in the array or in a subset of the array.
      Overrides:
      range in class ArrayVector.Integers
      Parameters:
      indices - supplier of indices of the values to examine for computing the range, or null for the 0, 1, 2, … n-1 sequence.
      n - number of indices to get from the supplier.
      Returns:
      the range of all values at the given indices.