Interface Seq<T>

All Superinterfaces:
BaseSeq<T>, IntFunction<T>, Iterable<T>, RandomAccess
All Known Subinterfaces:
ISeq<T>, MSeq<T>
All Known Implementing Classes:
ArrayISeq, ArrayMSeq, ArraySeq, CharSeq, Empty.EmptyISeq, Empty.EmptyMSeq

public interface Seq<T> extends BaseSeq<T>, IntFunction<T>
General interface for a ordered, fixed sized, object sequence.
Use the asList() method to work together with the Java Collection Framework.
Since:
1.0
Version:
5.2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Seq<?>
    Single instance of an empty Seq.
  • Method Summary

    Modifier and Type
    Method
    Description
    append(Iterable<? extends T> values)
    Return a new Seq with the given values appended.
    default Seq<T>
    append(T... values)
    Return a new Seq with the given values appended.
    default T
    apply(int index)
    Return the value at the given index.
    default ISeq<T>
    Return this sequence as ISeq instance.
    default List<T>
    Returns a fixed-size list backed by the specified sequence.
    default MSeq<T>
    Return this sequence as MSeq instance.
    static <T> Seq<T>
    concat(Seq<? extends T> a, Seq<? extends T> b)
    Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the second sequence.
    static <T> Seq<T>
    concat(Seq<? extends T> a, T... b)
    Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the vararg array.
    static <T> Seq<T>
    concat(T a, Seq<? extends T> b)
    Return a sequence whose elements are all the elements of the first element followed by all the elements of the sequence.
    default boolean
    contains(Object element)
    Returns true if this sequence contains the specified element.
    static <T> Seq<T>
    Return an empty Seq.
    static boolean
    equals(BaseSeq<?> seq, Object obj)
    Unified method for compare to sequences for equality.
    boolean
    equals(Object object)
    Compares the specified object with this sequence for equality.
    default boolean
    forAll(Predicate<? super T> predicate)
    Tests whether a predicate holds for all elements of this sequence.
    int
    Returns the hash code value for this sequence.
    static int
    hashCode(BaseSeq<?> seq)
    Unified method for calculating the hash code of every Seq implementation.
    default int
    indexOf(Object element)
    Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    indexOf(Object element, int start)
    Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    indexOf(Object element, int start, int end)
    Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    indexWhere(Predicate<? super T> predicate)
    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.
    default int
    indexWhere(Predicate<? super T> predicate, int start)
    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.
    default int
    indexWhere(Predicate<? super T> predicate, int start, int end)
    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.
    default boolean
    Test whether the given array is sorted in ascending order.
    default boolean
    isSorted(Comparator<? super T> comparator)
    Test whether the given array is sorted in ascending order.
    default int
    Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    lastIndexOf(Object element, int end)
    Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    lastIndexOf(Object element, int start, int end)
    Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
    default int
    lastIndexWhere(Predicate<? super T> predicate)
    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.
    default int
    lastIndexWhere(Predicate<? super T> predicate, int end)
    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.
    default int
    lastIndexWhere(Predicate<? super T> predicate, int start, int end)
    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.
    <B> Seq<B>
    map(Function<? super T,? extends B> mapper)
    Builds a new sequence by applying a function to all elements of this sequence.
    static <T> Seq<T>
    of(Iterable<? extends T> values)
    Create a new Seq from the given values.
    static <T> Seq<T>
    of(Supplier<? extends T> supplier, int length)
    Creates a new sequence, which is filled with objects created be the given supplier.
    static <T> Seq<T>
    of(T... values)
    Create a new Seq from the given values.
    default Stream<T>
    Returns a possibly parallel Stream with this sequence as its source.
    prepend(Iterable<? extends T> values)
    Return a new Seq with the given values prepended.
    default Seq<T>
    prepend(T... values)
    Return a new Seq with the given values prepended.
    default int
     
    subSeq(int start)
    Returns a view of the portion of this sequence between the specified start, inclusive, and end, exclusive.
    subSeq(int start, int end)
    Returns a view of the portion of this sequence between the specified start, inclusive, and end, exclusive.
    default Object[]
    Return an array containing all of the elements in this sequence in right order.
    default <B> B[]
    toArray(B[] array)
    Return an array containing all of the elements in this sequence in right order; the runtime type of the returned array is that of the specified array.
    default <B> B[]
    toArray(IntFunction<B[]> generator)
    Returns an array containing the elements of this sequence, using the provided generator function to allocate the returned array.
    static <T> Collector<T,?,Seq<T>>
    Returns a Collector that accumulates the input elements into a new Seq.
    static <T> Collector<T,?,Seq<T>>
    toSeq(int maxSize)
    Returns a Collector that accumulates the last n input elements into a new Seq.
    default String
    toString(String separator)
    Create a string representation of the given sequence.
    default String
    toString(String prefix, String separator, String suffix)
    Create a string representation of the given sequence.
    static <T> Seq<T>
    viewOf(BaseSeq<? extends T> seq)
    Returns a sequence backed by the specified seq.
    static <T> Seq<T>
    viewOf(List<? extends T> list)
    Returns a sequence backed by the specified list.
    static <T> Seq<T>
    viewOf(T[] array)
    Returns a fixed-size sequence backed by the specified array.

    Methods inherited from interface io.jenetics.util.BaseSeq

    forEach, get, isEmpty, iterator, length, listIterator, nonEmpty, spliterator, stream
  • Field Details

    • EMPTY

      static final Seq<?> EMPTY
      Single instance of an empty Seq.
      Since:
      3.3
  • Method Details

    • apply

      default T apply(int index)
      Return the value at the given index.
      Specified by:
      apply in interface IntFunction<T>
      Parameters:
      index - index of the element to return.
      Returns:
      the value at the given index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range index < 0 || index >= size().
      Since:
      3.9
      See Also:
    • size

      default int size()
      Returns:
      the size of this sequence
      See Also:
    • forAll

      default boolean forAll(Predicate<? super T> predicate)
      Tests whether a predicate holds for all elements of this sequence.
      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.
      Throws:
      NullPointerException - if the given predicate is null.
    • parallelStream

      default Stream<T> parallelStream()
      Returns a possibly parallel Stream with this sequence as its source. It is allowable for this method to return a sequential stream.
      Returns:
      a possibly parallel Stream over the elements in this collection
      Since:
      3.0
    • contains

      default boolean contains(Object element)
      Returns true if this sequence contains the specified element.
      Parameters:
      element - element whose presence in this sequence is to be tested. The tested element can be null.
      Returns:
      true if this sequence contains the specified element
    • indexOf

      default int indexOf(Object element)
      Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      Returns:
      the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
    • indexOf

      default int indexOf(Object element, int start)
      Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      start - the start index (inclusively) for the element search.
      Returns:
      the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || start > length()).
    • indexOf

      default int indexOf(Object element, int start, int end)
      Returns the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      start - the start index (inclusively) for the element search.
      end - the end index (exclusively) for the element search.
      Returns:
      the index of the first occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || end > length() || start > end).
    • indexWhere

      default int indexWhere(Predicate<? super T> predicate)

      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);
      Parameters:
      predicate - the search predicate.
      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.
      Throws:
      NullPointerException - if the given predicate is null.
    • indexWhere

      default int indexWhere(Predicate<? super T> predicate, int start)

      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);
      Parameters:
      predicate - the search predicate.
      start - the search start 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.
      Throws:
      NullPointerException - if the given predicate is null.
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || start > length()).
    • indexWhere

      default int indexWhere(Predicate<? super T> predicate, int start, int end)

      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);
      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.
      Throws:
      NullPointerException - if the given predicate is null.
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || end > length() || start > end).
    • lastIndexOf

      default int lastIndexOf(Object element)
      Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      Returns:
      the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
    • lastIndexOf

      default int lastIndexOf(Object element, int end)
      Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      end - the search end index
      Returns:
      the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (end < 0 || end > length()).
    • lastIndexOf

      default int lastIndexOf(Object element, int start, int end)
      Returns the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element.
      Parameters:
      element - element to search for, can be null
      start - the search start index
      end - the search end index
      Returns:
      the index of the last occurrence of the specified element in this sequence, or -1 if this sequence does not contain the element
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || end > length() || start > end).
    • lastIndexWhere

      default int lastIndexWhere(Predicate<? super T> predicate)
      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.
      Parameters:
      predicate - the search predicate.
      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.
      Throws:
      NullPointerException - if the given predicate is null.
    • lastIndexWhere

      default int lastIndexWhere(Predicate<? super T> predicate, int end)
      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.
      Parameters:
      predicate - the search predicate.
      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.
      Throws:
      NullPointerException - if the given predicate is null.
      IndexOutOfBoundsException - for an illegal end point index value (end < 0 || end > length()).
    • lastIndexWhere

      default int lastIndexWhere(Predicate<? super T> predicate, int start, int end)
      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.
      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.
      Throws:
      NullPointerException - if the given predicate is null.
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || end > length() || start > end).
    • map

      <B> Seq<B> map(Function<? super T,? extends B> mapper)
      Builds a new sequence by applying a function to all elements of this sequence.
      Type Parameters:
      B - the element type of the returned collection.
      Parameters:
      mapper - the function to apply to each element.
      Returns:
      a new sequence of type That resulting from applying the given function f to each element of this sequence and collecting the results.
      Throws:
      NullPointerException - if the element mapper is null.
    • append

      default Seq<T> append(T... values)
      Return a new Seq with the given values appended.
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values appended.
      Throws:
      NullPointerException - if the given values array is null
      Since:
      3.4
    • append

      Seq<T> append(Iterable<? extends T> values)
      Return a new Seq with the given values appended.
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values appended.
      Throws:
      NullPointerException - if the given values iterable is null
      Since:
      3.4
    • prepend

      default Seq<T> prepend(T... values)
      Return a new Seq with the given values prepended.
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values prepended.
      Throws:
      NullPointerException - if the given values array is null
      Since:
      3.4
    • prepend

      Seq<T> prepend(Iterable<? extends T> values)
      Return a new Seq with the given values prepended.
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values prepended.
      Throws:
      NullPointerException - if the given values array is null
      Since:
      3.4
    • asList

      default List<T> asList()
      Returns a fixed-size list backed by the specified sequence. (Changes to the returned list "write through" to the array.) The returned list is fixed size, serializable and implements RandomAccess.
      Returns:
      a list view of this sequence
    • toArray

      default Object[] toArray()
      Return an array containing all of the elements in this sequence in right order. The returned array will be "safe" in that no references to it are maintained by this sequence. (In other words, this method must allocate a new array.) The caller is thus free to modify the returned array.
      Returns:
      an array containing all of the elements in this list in right order
      See Also:
    • toArray

      default <B> B[] toArray(B[] array)
      Return an array containing all of the elements in this sequence in right order; the runtime type of the returned array is that of the specified array. If this sequence fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the length of this array.

      If this sequence fits in the specified array with room to spare (i.e., the array has more elements than this array), the element in the array immediately following the end of this array is set to null. (This is useful in determining the length of the array only if the caller knows that the list does not contain any null elements.)

      Type Parameters:
      B - the runtime type of the array to contain the sequence
      Parameters:
      array - the array into which the elements of this array 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 array
      Throws:
      ArrayStoreException - if the runtime type of the specified array is not a super type of the runtime type of every element in this array
      NullPointerException - if the given array is null.
      See Also:
    • toArray

      default <B> B[] toArray(IntFunction<B[]> generator)
      Returns an array containing the elements of this sequence, using the provided generator function to allocate the returned array.
      Type Parameters:
      B - the element type of the resulting array
      Parameters:
      generator - a function which produces a new array of the desired type and the provided length
      Returns:
      an array containing the elements in this sequence
      Throws:
      ArrayStoreException - if the runtime type of the specified array is not a super type of the runtime type of every element in this array
      NullPointerException - if the given generator is null.
      Since:
      4.4
    • subSeq

      Seq<T> subSeq(int start)
      Returns a view of the portion of this sequence between the specified start, inclusive, and end, exclusive. (If start and end are equal, the returned sequence has the length zero.) The returned sequence is backed by this sequence, so non-structural changes in the returned sequence are reflected in this sequence, and vice-versa.

      This method eliminates the need for explicit range operations (of the populationSort that commonly exist for arrays). Any operation that expects an sequence can be used as a range operation by passing an sub sequence view instead of an whole sequence.

      Parameters:
      start - lower end point (inclusive) of the sub array.
      Returns:
      a view of the specified range within this array.
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || start > length()).
    • subSeq

      Seq<T> subSeq(int start, int end)
      Returns a view of the portion of this sequence between the specified start, inclusive, and end, exclusive. (If start and end are equal, the returned sequence has the length zero.) The returned sequence is backed by this sequence, so non-structural changes in the returned sequence are reflected in this array, and vice-versa.

      This method eliminates the need for explicit range operations (of the populationSort that commonly exist for arrays). Any operation that expects an array can be used as a range operation by passing an sub sequence view instead of an whole sequence.

      Parameters:
      start - low end point (inclusive) of the sub sequence.
      end - high end point (exclusive) of the sub sequence.
      Returns:
      a view of the specified range within this sequence.
      Throws:
      IndexOutOfBoundsException - for an illegal end point index value (start < 0 || end > length() || start > end).
    • isSorted

      default boolean isSorted()
      Test whether the given array is sorted in ascending order.
      Returns:
      true if the given array is sorted in ascending order, false otherwise.
      Throws:
      NullPointerException - if the given array or one of it's element is null.
    • isSorted

      default boolean isSorted(Comparator<? super T> comparator)
      Test whether the given array is sorted in ascending order. The order of the array elements is defined by the given comparator.
      Parameters:
      comparator - the comparator which defines the order.
      Returns:
      true if the given array is sorted in ascending order, false otherwise.
      Throws:
      NullPointerException - if the given array or one of it's element or the comparator is null.
    • asMSeq

      default MSeq<T> asMSeq()
      Return this sequence as MSeq instance. If this is not a MSeq a new seq is created.
      Returns:
      a MSeq with this values
      Since:
      3.8
    • asISeq

      default ISeq<T> asISeq()
      Return this sequence as ISeq instance. If this is not a ISeq a new seq is created.
      Returns:
      a ISeq with this values
      Since:
      3.8
    • hashCode

      int hashCode()
      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()); }
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this list
      See Also:
    • equals

      boolean equals(Object object)
      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.
      Overrides:
      equals in class Object
      Parameters:
      object - 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:
    • toString

      default String toString(String prefix, String separator, String suffix)
      Create a string representation of the given sequence.
      Parameters:
      prefix - the prefix of the string representation; e.g '['.
      separator - the separator of the array elements; e.g. ','.
      suffix - the suffix of the string representation; e.g. ']'.
      Returns:
      the string representation of this sequence.
    • toString

      default String toString(String separator)
      Create a string representation of the given sequence.
      Parameters:
      separator - the separator of the array elements; e.g. ','.
      Returns:
      the string representation of this sequence.
    • hashCode

      static int hashCode(BaseSeq<?> seq)
      Unified method for calculating the hash code of every Seq implementation. 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()); }
      Parameters:
      seq - the sequence to calculate the hash code for.
      Returns:
      the hash code of the given sequence.
      See Also:
    • equals

      static boolean equals(BaseSeq<?> seq, Object obj)
      Unified method for compare to sequences for equality.
      Parameters:
      seq - the sequence to test for equality.
      obj - the object to test for equality with the sequence.
      Returns:
      true if the given objects are sequences and contain the same objects in the same order, false otherwise.
      See Also:
    • concat

      static <T> Seq<T> concat(T a, Seq<? extends T> b)
      Return a sequence whose elements are all the elements of the first element followed by all the elements of the sequence.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first element
      b - the appending sequence
      Returns:
      the concatenation of the two inputs
      Throws:
      NullPointerException - if one of the second arguments is null
      Since:
      5.0
    • concat

      static <T> Seq<T> concat(Seq<? extends T> a, T... b)
      Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the vararg array.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence
      b - the vararg elements
      Returns:
      the concatenation of the two inputs
      Throws:
      NullPointerException - if one of the arguments is null
      Since:
      5.0
    • concat

      static <T> Seq<T> concat(Seq<? extends T> a, Seq<? extends T> b)
      Return a sequence whose elements are all the elements of the first sequence followed by all the elements of the second sequence.
      Type Parameters:
      T - the type of the sequence elements
      Parameters:
      a - the first sequence
      b - the second sequence
      Returns:
      the concatenation of the two input sequences
      Throws:
      NullPointerException - if one of the arguments is null
      Since:
      5.0
    • empty

      static <T> Seq<T> empty()
      Return an empty Seq.
      Type Parameters:
      T - the element type of the returned Seq.
      Returns:
      an empty Seq.
      Since:
      3.3
    • toSeq

      static <T> Collector<T,?,Seq<T>> toSeq()
      Returns a Collector that accumulates the input elements into a new Seq.
      Type Parameters:
      T - the type of the input elements
      Returns:
      a Collector which collects all the input elements into a Seq, in encounter order
    • toSeq

      static <T> Collector<T,?,Seq<T>> toSeq(int maxSize)
      Returns a Collector that accumulates the last n input elements into a new Seq.
      Type Parameters:
      T - the type of the input elements
      Parameters:
      maxSize - the maximal size of the collected sequence
      Returns:
      a Collector which collects maximal maxSize of the input elements into an ISeq, in encounter order
      Throws:
      IllegalArgumentException - if the maxSize is negative
      Since:
      5.0
    • of

      @SafeVarargs static <T> Seq<T> of(T... values)
      Create a new Seq from the given values.
      Type Parameters:
      T - the element type
      Parameters:
      values - the array values.
      Returns:
      a new Seq with the given values.
      Throws:
      NullPointerException - if the values array is null.
    • of

      static <T> Seq<T> of(Iterable<? extends T> values)
      Create a new Seq from the given values.
      Type Parameters:
      T - the element type
      Parameters:
      values - the array values.
      Returns:
      a new Seq with the given values.
      Throws:
      NullPointerException - if the values array is null.
    • of

      static <T> Seq<T> of(Supplier<? extends T> supplier, int length)
      Creates a new sequence, which is filled with objects created be the given supplier.
      Type Parameters:
      T - the element type of the sequence
      Parameters:
      supplier - the Supplier which creates the elements, the returned sequence is filled with
      length - the length of the returned sequence
      Returns:
      a new sequence filled with elements given by the supplier
      Throws:
      NegativeArraySizeException - if the given length is negative
      NullPointerException - if the given supplier is null
      Since:
      3.3
    • viewOf

      static <T> Seq<T> viewOf(BaseSeq<? extends T> seq)
      Returns a sequence backed by the specified seq. (Changes to the given sequence (if writeable) are "write through" to the returned sequence.) This method acts as bridge between basic sequences and sequence-based APIs.
      Type Parameters:
      T - the element type
      Parameters:
      seq - the basic sequence containing the elements
      Returns:
      a sequence view of the given seq
      Throws:
      NullPointerException - if the given list is null
      Since:
      6.0
    • viewOf

      static <T> Seq<T> viewOf(List<? extends T> list)
      Returns a sequence backed by the specified list. (Changes to the given list are "write through" to the returned sequence.) This method acts as bridge between collection-based and sequence-based APIs.
      Type Parameters:
      T - the element type
      Parameters:
      list - the list containing the elements
      Returns:
      a sequence view of the given list
      Throws:
      NullPointerException - if the given list is null
      Since:
      4.2
    • viewOf

      static <T> Seq<T> viewOf(T[] array)
      Returns a fixed-size sequence backed by the specified array. (Changes to the given array are "write through" to the returned sequence.) This method acts as bridge between array-based and sequence-based APIs.
      Type Parameters:
      T - the element type
      Parameters:
      array - the array containing the sequence elements
      Returns:
      a sequence view of the given array
      Throws:
      NullPointerException - if the given array is null
      Since:
      4.2