Interface ISeq<T>

All Superinterfaces:
BaseSeq<T>, Copyable<MSeq<T>>, IntFunction<T>, Iterable<T>, RandomAccess, Seq<T>
All Known Implementing Classes:
io.jenetics.internal.collection.ArrayISeq, CharSeq

public interface ISeq<T> extends Seq<T>, Copyable<MSeq<T>>
Immutable, ordered, fixed sized sequence.
Since:
1.0
Version:
5.2
See Also:
  • Field Details

    • EMPTY

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

    • subSeq

      ISeq<T> subSeq(int start, int end)
      Description copied from interface: Seq
      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 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 a subsequence view instead of a whole sequence.

      Specified by:
      subSeq in interface Seq<T>
      Parameters:
      start - low-end point (inclusive) of the subsequence.
      end - high-end point (exclusive) of the subsequence.
      Returns:
      a view of the specified range within this sequence.
    • subSeq

      ISeq<T> subSeq(int start)
      Description copied from interface: Seq
      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 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 a sequence can be used as a range operation by passing a subsequence view instead of a whole sequence.

      Specified by:
      subSeq in interface Seq<T>
      Parameters:
      start - lower end point (inclusive) of the subarray.
      Returns:
      a view of the specified range within this array.
    • map

      <B> ISeq<B> map(Function<? super T,? extends B> mapper)
      Description copied from interface: Seq
      Builds a new sequence by applying a function to all elements of this sequence.
      Specified by:
      map in interface Seq<T>
      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.
    • append

      default ISeq<T> append(T... values)
      Description copied from interface: Seq
      Return a new Seq with the given values appended.
      Specified by:
      append in interface Seq<T>
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values appended.
    • append

      ISeq<T> append(Iterable<? extends T> values)
      Description copied from interface: Seq
      Return a new Seq with the given values appended.
      Specified by:
      append in interface Seq<T>
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values appended.
    • prepend

      default ISeq<T> prepend(T... values)
      Description copied from interface: Seq
      Return a new Seq with the given values prepended.
      Specified by:
      prepend in interface Seq<T>
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values prepended.
    • prepend

      ISeq<T> prepend(Iterable<? extends T> values)
      Description copied from interface: Seq
      Return a new Seq with the given values prepended.
      Specified by:
      prepend in interface Seq<T>
      Parameters:
      values - the values to append
      Returns:
      a new Seq with the elements of this sequence and the given values prepended.
    • copy

      MSeq<T> copy()
      Return a shallow copy of this sequence. The sequence elements are not cloned.
      Specified by:
      copy in interface Copyable<T>
      Returns:
      a shallow copy of this sequence.
    • concat

      static <T> ISeq<T> concat(T a, ISeq<? 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> ISeq<T> concat(ISeq<? 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> ISeq<T> concat(ISeq<? extends T> a, ISeq<? 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> ISeq<T> empty()
      Return an empty ISeq.
      Type Parameters:
      T - the element type of the returned ISeq.
      Returns:
      an empty ISeq.
      Since:
      3.3
    • toISeq

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

      static <T> Collector<T,?,ISeq<T>> toISeq(int maxSize)
      Returns a Collector that accumulates the last n input elements into a new ISeq.
      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> ISeq<T> of(T... values)
      Create a new ISeq from the given values.
      Type Parameters:
      T - the element type
      Parameters:
      values - the array values.
      Returns:
      a new ISeq with the given values.
      Throws:
      NullPointerException - if the values array is null.
    • of

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

      static <T> ISeq<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.2
    • upcast

      static <A, B extends A> ISeq<A> upcast(ISeq<B> seq)
      Allows a safe (without compiler warning) upcast from B to A. Since ISeq instances are immutable, an upcast will be always safe.
      // The sequence which we want to case.
      final ISeq<? extends Number> ints = ISeq.of(1, 2, 3, 4, 5);
      
      // These casts are possible without warning.
      final ISeq<Object> objects = ISeq.upcast(ints);
      final ISeq<Number> numbers = ISeq.upcast(ints);
      
      // This cast will, of course, still fail.
      final ISeq<String> strings = ISeq.upcast(ints);
      final ISeq<Integer> integers = ISeq.upcast(ints);
      
      Type Parameters:
      A - the super-object type
      B - the sub-object type
      Parameters:
      seq - the sequence to cast safely
      Returns:
      the cast instance of the given seq
      Since:
      3.6