Class ArrayVector.Doubles

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

static final class ArrayVector.Doubles extends ArrayVector<Double>
A vector backed by an array of type double[].
  • Field Details

    • serialVersionUID

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

      private final double[] array
      The backing array.
  • Constructor Details

    • Doubles

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

    • getElementType

      public Class<Double> getElementType()
      Returns the type of elements in the backing array.
      Specified by:
      getElementType in interface CheckedContainer<Double>
      Specified by:
      getElementType in class Vector
      Returns:
      the type of elements in this vector.
      See Also:
    • isSinglePrecision

      public boolean isSinglePrecision()
      Returns whether values are convertible to float type.
      Overrides:
      isSinglePrecision in class Vector
      Returns:
      whether values in this vector can be casted to float primitive type.
      See Also:
    • size

      public int size()
      Returns the length of the backing array.
      Specified by:
      size in interface Collection<Number>
      Specified by:
      size in interface List<Number>
      Specified by:
      size in class Vector
      Returns:
      the number of elements in this vector.
    • isNaN

      public boolean isNaN(int index)
      Returns true if the value at the given index is NaN.
      Overrides:
      isNaN in class ArrayVector<Double>
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      true if the value at the given index is NaN.
    • stringValue

      public String stringValue(int index)
      Returns the string representation at the given index.
      Specified by:
      stringValue in class Vector
      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:
    • doubleValue

      public double doubleValue(int index)
      Returns the value at the given index.
      Specified by:
      doubleValue in class Vector
      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)
      Returns the value casted as a float, since we may loose precision but the result of the cast is not completely wrong (at worst we get zero of infinity values if the magnitude of the double value was too small or too large).
      Overrides:
      floatValue in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index.
      See Also:
    • get

      public Number get(int index)
      Returns the value at the given index.
      Specified by:
      get in interface List<Number>
      Specified by:
      get in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      Returns:
      the value at the given index (may be null).
    • set

      public Number set(int index, Number value)
      Sets the value at the given index.
      Specified by:
      set in interface List<Number>
      Specified by:
      set in class Vector
      Parameters:
      index - the index in the [0 … size-1] range.
      value - the value to set at the given index.
      Returns:
      the value previously stored at the given index.
    • fill

      public void fill(int fromIndex, int toIndex, Number value)
      Sets the value of all elements in the given range.
      Overrides:
      fill in class Vector
      Parameters:
      fromIndex - index of the first element (inclusive) to be filled with the specified value.
      toIndex - index of the last element (exclusive) to be filled with the specified value.
      value - the value to be stored in elements of the vector.
    • indexOf

      int indexOf(int toSearch, int index, boolean equality)
      Finds index of a match or mismatch (depending on equality).
      Overrides:
      indexOf in class Vector
      Parameters:
      toSearch - index of the value to search.
      index - index of the first value where to start the search.
      equality - whether we search the first equal value, or the first different value.
      Returns:
      index of the value found, or the vector size if the value has not been found.
    • isEmptyOrNaN

      public boolean isEmptyOrNaN()
      Returns true if this vector is empty or contains only NaN values.
      Overrides:
      isEmptyOrNaN in class Vector
      Returns:
      whether this vector is empty or contains only NaN values.
    • equals

      boolean equals(int lower, int upper, Vector other, int otherOffset)
      Returns whether this vector in the given range is equal to the specified vector.
      Overrides:
      equals in class Vector
      Parameters:
      lower - index of the first value to compare in this vector, inclusive.
      upper - index after the last value to compare in this vector.
      other - the other vector to compare values with this vector. May be this.
      otherOffset - index of the first element to compare in the other vector.
      Returns:
      whether values over the specified range of the two vectors are equal.
    • range

      NumberRange<Double> 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 Vector
      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.
    • buffer

      public Optional<Buffer> buffer()
      Wraps this vector in a buffer.
      Overrides:
      buffer in class Vector
      Returns:
      the vector data as a buffer. Absent if this vector is not backed by an array or a buffer.
    • doubleValues

      public double[] doubleValues()
      Returns a copy of current data as a floating point array.
      Overrides:
      doubleValues in class Vector
      Returns:
      a copy of all floating point values in this vector.
      See Also:
    • floatValues

      public float[] floatValues()
      Returns a copy of current data as a floating point array.
      Overrides:
      floatValues in class Vector
      Returns:
      a copy of all floating point values in this vector.
      See Also:
    • hashCode

      public int hashCode()
      Applies hash code contract specified Vector.hashCode().
      Specified by:
      hashCode in interface Collection<Number>
      Specified by:
      hashCode in interface List<Number>
      Overrides:
      hashCode in class Vector
      Returns:
      a hash code value for the values in this vector.