Class ArraySeq<T>

java.lang.Object
ArraySeq<T>
All Implemented Interfaces:
BaseSeq<T>, Seq<T>, Serializable, Iterable<T>, IntFunction<T>, RandomAccess
Direct Known Subclasses:
ArrayISeq, ArrayMSeq

public abstract class ArraySeq<T> extends Object implements Seq<T>, RandomAccess, Serializable
Since:
1.4
Version:
5.2
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • get

      public final T get(int index)
      Description copied from interface: BaseSeq
      Return the value at the given index.
      Specified by:
      get in interface BaseSeq<T>
      Parameters:
      index - index of the element to return.
      Returns:
      the value at the given index.
    • forEach

      public void forEach(Consumer<? super T> consumer)
      Specified by:
      forEach in interface BaseSeq<T>
      Specified by:
      forEach in interface Iterable<T>
    • forAll

      public boolean forAll(Predicate<? super T> predicate)
      Description copied from interface: Seq
      Tests whether a predicate holds for all elements of this sequence.
      Specified by:
      forAll in interface Seq<T>
      Parameters:
      predicate - the predicate to use to test the elements.
      Returns:
      true if the given predicate p holds for all elements of this sequence, false otherwise.
    • indexWhere

      public int indexWhere(Predicate<? super T> predicate, int start, int end)
      Description copied from interface: Seq

      Returns the index of the first element on which the given predicate returns true, or -1 if the predicate returns false for every sequence element.

      // Finding index of first null value. final int index = seq.indexOf(o -> o == null); // Assert of no null values. assert (sequence.indexOf(o -> o == null) == -1);
      Specified by:
      indexWhere in interface Seq<T>
      Parameters:
      predicate - the search predicate.
      start - the search start index
      end - the search end index
      Returns:
      the index of the first element on which the given predicate returns true, or -1 if the predicate returns false for every sequence element.
    • lastIndexWhere

      public int lastIndexWhere(Predicate<? super T> predicate, int start, int end)
      Description copied from interface: Seq
      Returns the index of the last element on which the given predicate returns true, or -1 if the predicate returns false for every sequence element.
      Specified by:
      lastIndexWhere in interface Seq<T>
      Parameters:
      predicate - the search predicate.
      start - the search start index
      end - the search end index
      Returns:
      the index of the last element on which the given predicate returns true, or -1 if the predicate returns false for every sequence element.
    • length

      public int length()
      Description copied from interface: BaseSeq
      Return the length of this sequence. Once the sequence is created, the length can't be changed.
      Specified by:
      length in interface BaseSeq<T>
      Returns:
      the length of this sequence.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Description copied from interface: Seq
      Returns the hash code value for this sequence. The hash code is defined as followed:
      int hashCode = 1; final Iterator<E> it = seq.iterator(); while (it.hasNext()) { final E obj = it.next(); hashCode = 31*hashCode + (obj == null ? 0 : obj.hashCode()); }
      Specified by:
      hashCode in interface Seq<T>
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this list
      See Also:
    • equals

      public boolean equals(Object obj)
      Description copied from interface: Seq
      Compares the specified object with this sequence for equality. Returns true if and only if the specified object is also a sequence, both sequence have the same size, and all corresponding pairs of elements in the two sequences are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) This definition ensures that the equals method works properly across different implementations of the Seq interface.
      Specified by:
      equals in interface Seq<T>
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared for equality with this sequence.
      Returns:
      true if the specified object is equal to this sequence, false otherwise.
      See Also: