接口 Sequence<T>

  • 所有超级接口:
    java.util.Iterator<T>

    public interface Sequence<T>
    extends java.util.Iterator<T>
    A sequence of elements supporting support map and reduce operations. Sequence like Stream, but comes with more convenient methods. Sequence not support parallel operations, so the implementation can be simpler.
    • 方法概要

      所有方法 静态方法 实例方法 抽象方法 默认方法 已过时的方法 
      修饰符和类型 方法 说明
      default boolean allMatch​(java.util.function.Predicate<? super T> predicate)
      If all elements in this sequence meet the predicate.
      default boolean anyMatch​(java.util.function.Predicate<? super T> predicate)
      If any element in this sequence meet the predicate.
      default java.lang.Iterable<T> asIterable()
      Return a iterable that wrap this sequence, and can iterate only once.
      default java.util.stream.Stream<T> asStream()
      Return a Stream that wrap this sequence.
      default java.util.Optional<T> at​(long seq)
      Return the element at index, return empty Optional if this Sequence do not have enough elements.
      default double averageDouble​(java.util.function.ToDoubleFunction<T> function)
      Calculate the average value of values calculated by the elements.
      default double averageLong​(java.util.function.ToLongFunction<T> function)
      Calculate the average value of values calculated by the elements.
      default Sequence<java.util.List<T>> chunked​(int size)
      Buffer this sequence into a sequence of lists each not exceeding the given size.
      default <R> R collect​(CollectConsumer<? super T,​? extends R> collectConsumer)
      Collect elements to collection.
      default Sequence<T> concat​(java.util.Collection<? extends Sequence<T>> sequences)
      Return a Sequence contains elements in all Sequences.
      default Sequence<T> concat​(Sequence<T> sequence)
      Return a Sequence contains elements in both Sequence.
      default long count()
      return the count of elements
      default Sequence<T> distinct()
      Return a sequence do not contains duplicated elements.
      default <E> Sequence<T> distinctBy​(java.util.function.Function<? super T,​E> keyMapper)
      Return a sequence do not contains duplicated elements.
      default Sequence<T> drop​(long size)
      Drop first N elements
      default Sequence<T> dropWhile​(java.util.function.Predicate<? super T> predicate)
      Drop elements while all meet elements pass the predicate
      default Sequence<T> filter​(java.util.function.Predicate<? super T> filter)
      filter operator
      default Sequence<T> filterNonNull()
      Return a Sequence only contains non-null values.
      default Sequence<T> filterOrConsume​(java.util.function.Predicate<? super T> filter, java.util.function.Consumer<T> consumer)
      filter operator.
      default java.util.Optional<T> find​(java.util.function.Predicate<? super T> predicate)
      Find and return the first element meet the predicate in Sequence.
      default java.util.Optional<T> findLast​(java.util.function.Predicate<? super T> predicate)
      Find and return the lat element meet the predicate in Sequence.
      default java.util.Optional<T> first()
      Return the first element of Sequence.
      default <R> Sequence<R> flatMap​(java.util.function.Function<? super T,​? extends Sequence<R>> mapper)
      flat map operator
      default void forEach​(java.util.function.Consumer<? super T> consumer)
      Consumer the remained element in this Sequence.
      static <T> Sequence<T> generate​(java.util.function.LongFunction<T> generator)
      Generate a sequence, according to current index
      static <T> Sequence<T> generate​(java.util.function.Supplier<T> supplier)
      Generate a sequence, from value supplier
      static <T> Sequence<T> generate​(java.util.function.Supplier<T> initial, java.util.function.UnaryOperator<T> generator)
      Generate a sequence, from initial value
      default <K,​R>
      java.util.Map<K,​R>
      groupAndCollect​(java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Supplier<? extends CollectConsumer<? super T,​? extends R>> collector)
      Group the element by key mapper; for per single key, collect elements with this key to the result value.
      default <K,​R>
      java.util.Map<K,​R>
      groupAndReduce​(java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Supplier<R> initial, java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
      Group the element by key mapper; for per single key, reduce elements with this key to the result value.
      default <K,​R extends java.util.Collection<T>>
      java.util.Map<K,​R>
      groupToCollection​(java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Supplier<R> collectionSupplier)
      Group the element by key mapper; for per single key, reduce elements with this key to the result value.
      default <K> java.util.Map<K,​java.util.List<T>> groupToList​(java.util.function.Function<? super T,​? extends K> keyMapper)
      Group the element by key mapper; for per single key, a immutable list contains all elements with this key is constructed.
      boolean hasNext()  
      default void joinTo​(java.lang.Appendable appendable, java.lang.CharSequence sep, java.lang.CharSequence prefix, java.lang.CharSequence suffix)
      Join the elements to String out
      default java.lang.String joinToString​(java.lang.CharSequence sep)
      Join the elements to String
      default java.lang.String joinToString​(java.lang.CharSequence sep, java.lang.CharSequence prefix, java.lang.CharSequence suffix)
      Join the elements to String
      default java.util.Optional<T> last()
      Return the last element of Sequence.
      default <R> Sequence<R> map​(java.util.function.Function<? super T,​? extends R> mapper)
      map operator
      default java.util.Optional<T> max()
      Get the max value by natural order comparator.
      default java.util.Optional<T> maxBy​(java.util.Comparator<? super T> comparator)
      Get the max value by comparator.
      default java.util.Optional<T> min()
      Get the min value by natural order comparator.
      default java.util.Optional<T> minBy​(java.util.Comparator<? super T> comparator)
      Get the min value by comparator.
      T next()  
      default boolean noneMatch​(java.util.function.Predicate<? super T> predicate)
      If no elements in this sequence meet the predicate.
      static <T> Sequence<T> of()
      Return a empty sequence
      static <T> Sequence<T> of​(java.lang.Iterable<T> iterable)
      Create sequence from iterable
      static <T> Sequence<T> of​(java.util.Collection<T> collection)
      Create sequence from collection.
      static <T> Sequence<T> of​(java.util.Iterator<T> iterator)
      Create sequence from iterator
      static <T> Sequence<T> of​(java.util.Optional<T> optional)
      Return a empty sequence
      static <T> Sequence<T> of​(java.util.stream.Stream<T> stream)
      Create a new Sequence from stream.
      static <T> Sequence<T> of​(T value)
      Return a empty sequence
      static <T> Sequence<T> of​(T... values)
      Create sequence from values, or array.
      default <R extends java.util.Collection<T>>
      PartitionResult<R>
      partitionAndCollect​(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<R> supplier)
      Partition the elements by predicate, and then collect elements.
      default <R> PartitionResult<R> partitionAndReduce​(java.util.function.Predicate<? super T> predicate, java.util.function.Supplier<R> initial, java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
      Partition the elements by predicate, and then do reducer for both Seq of elements.
      default PartitionResult<java.util.List<T>> partitionToList​(java.util.function.Predicate<? super T> predicate)
      Partition the elements by predicate, and then collect elements to immutable list.
      default Sequence<T> peek​(java.util.function.Consumer<? super T> consumer)
      Return a Sequence, with has a side effect when a element is take out, it is consume by specified consumer.
      default <R> R reduce​(R initialValue, java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
      reduce operator
      default void remove()
      已过时。
      default Sequence<T> sorted()
      Return a sorted Sequence, Sequence element type T should implement Comparable interface.
      default Sequence<T> sortedBy​(java.util.Comparator<? super T> comparator)
      Return a sorted Sequence.
      default double sumDouble​(java.util.function.ToDoubleFunction<T> function)
      Sum the double values calculated by the elements.
      default int sumInt​(java.util.function.ToIntFunction<T> function)
      Sum the int values calculated by the elements.
      default long sumLong​(java.util.function.ToLongFunction<T> function)
      Sum the long values calculated by the elements.
      default Sequence<T> take​(long size)
      Only take first n elements
      default Sequence<T> takeWhile​(java.util.function.Predicate<? super T> predicate)
      Take elements while all meet elements pass the predicate
      default java.util.ArrayList<T> toArrayList()
      reduce to array list.
      default <R extends java.util.Collection<T>>
      R
      toCollection​(java.util.function.Supplier<R> collectionSupplier)
      Collect elements to collection.
      default <K,​V>
      java.util.HashMap<K,​V>
      toHashMap​(java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Function<? super T,​? extends V> valueMapper)
      reduce to hash map
      default java.util.HashSet<T> toHashSet()
      reduce to hash set
      default java.util.List<T> toImmutableList()
      reduce to immutable List.
      default <K,​V>
      java.util.Map<K,​V>
      toImmutableMap​(java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Function<? super T,​? extends V> valueMapper)
      collect elements to immutable Map.
      default java.util.Set<T> toImmutableSet()
      reduce to immutable Set.
      default <K,​V,​R extends java.util.Map<K,​V>>
      R
      toMap​(java.util.function.Supplier<R> mapSupplier, java.util.function.Function<? super T,​? extends K> keyMapper, java.util.function.Function<? super T,​? extends V> valueMapper)
      collect elements to map
      static <S,​T>
      Sequence<Pair<S,​T>>
      zip​(Sequence<@NonNull S> s1, Sequence<@NonNull T> s2)
      Returns a sequence of values built from the elements of this sequence and the other sequence with the same index.
      • 从接口继承的方法 java.util.Iterator

        forEachRemaining
    • 方法详细资料

      • hasNext

        boolean hasNext()
        指定者:
        hasNext 在接口中 java.util.Iterator<T>
      • next

        T next()
        指定者:
        next 在接口中 java.util.Iterator<T>
      • remove

        @Deprecated
        default void remove()
        已过时。
        指定者:
        remove 在接口中 java.util.Iterator<T>
      • zip

        static <S,​T> Sequence<Pair<S,​T>> zip​(Sequence<@NonNull S> s1,
                                                         Sequence<@NonNull T> s2)
        Returns a sequence of values built from the elements of this sequence and the other sequence with the same index. The resulting sequence ends as soon as the shortest input sequence ends.
      • of

        static <T> Sequence<T> of​(java.util.Iterator<T> iterator)
        Create sequence from iterator
      • of

        static <T> Sequence<T> of​(java.lang.Iterable<T> iterable)
        Create sequence from iterable
      • of

        static <T> Sequence<T> of​(java.util.Collection<T> collection)
        Create sequence from collection. This method do not do defensive copy.
      • of

        static <T> Sequence<T> of​(java.util.stream.Stream<T> stream)
        Create a new Sequence from stream. The stream is then terminated.
      • of

        static <T> Sequence<T> of()
        Return a empty sequence
        类型参数:
        T - the element type
      • of

        static <T> Sequence<T> of​(T value)
        Return a empty sequence
        类型参数:
        T - the element type
      • of

        @SafeVarargs
        static <T> Sequence<T> of​(T... values)
        Create sequence from values, or array. This method do not do defensive copy.
      • of

        static <T> Sequence<T> of​(java.util.Optional<T> optional)
        Return a empty sequence
        类型参数:
        T - the element type
      • generate

        static <T> Sequence<T> generate​(java.util.function.Supplier<T> supplier)
        Generate a sequence, from value supplier
        类型参数:
        T - the value type
        返回:
        a sequence
      • generate

        static <T> Sequence<T> generate​(java.util.function.LongFunction<T> generator)
        Generate a sequence, according to current index
        类型参数:
        T - the value type
        返回:
        a sequence
      • generate

        static <T> Sequence<T> generate​(java.util.function.Supplier<T> initial,
                                        java.util.function.UnaryOperator<T> generator)
        Generate a sequence, from initial value
        类型参数:
        T - the value type
        参数:
        initial - the initial value supplier
        generator - generate value from previous value
        返回:
        a sequence
      • concat

        default Sequence<T> concat​(Sequence<T> sequence)
        Return a Sequence contains elements in both Sequence.
      • concat

        default Sequence<T> concat​(java.util.Collection<? extends Sequence<T>> sequences)
        Return a Sequence contains elements in all Sequences.
      • map

        default <R> Sequence<R> map​(java.util.function.Function<? super T,​? extends R> mapper)
        map operator
      • filter

        default Sequence<T> filter​(java.util.function.Predicate<? super T> filter)
        filter operator
      • filterOrConsume

        default Sequence<T> filterOrConsume​(java.util.function.Predicate<? super T> filter,
                                            java.util.function.Consumer<T> consumer)
        filter operator. If element is not accepted, call consumer for it.
      • flatMap

        default <R> Sequence<R> flatMap​(java.util.function.Function<? super T,​? extends Sequence<R>> mapper)
        flat map operator
      • distinctBy

        default <E> Sequence<T> distinctBy​(java.util.function.Function<? super T,​E> keyMapper)
        Return a sequence do not contains duplicated elements.
        参数:
        keyMapper - function to get a element key, to judge if elements are duplicated.
      • distinct

        default Sequence<T> distinct()
        Return a sequence do not contains duplicated elements.
      • filterNonNull

        default Sequence<T> filterNonNull()
        Return a Sequence only contains non-null values.
      • drop

        default Sequence<T> drop​(long size)
        Drop first N elements
        参数:
        size - the elements number to drop
      • dropWhile

        default Sequence<T> dropWhile​(java.util.function.Predicate<? super T> predicate)
        Drop elements while all meet elements pass the predicate
      • take

        default Sequence<T> take​(long size)
        Only take first n elements
      • takeWhile

        default Sequence<T> takeWhile​(java.util.function.Predicate<? super T> predicate)
        Take elements while all meet elements pass the predicate
      • at

        default java.util.Optional<T> at​(long seq)
        Return the element at index, return empty Optional if this Sequence do not have enough elements. The elements in Seq should not be null.
        参数:
        seq - the element index, start from zero
      • chunked

        default Sequence<java.util.List<T>> chunked​(int size)
        Buffer this sequence into a sequence of lists each not exceeding the given size.
        参数:
        size - the max size for buffer
      • sortedBy

        default Sequence<T> sortedBy​(java.util.Comparator<? super T> comparator)
        Return a sorted Sequence. A comparator is needed for sort. If T is sub type of Comparable and want to use it's compare impl for sorting, Comparator.naturalOrder() can be passed in.
        参数:
        comparator - the comparator to sort sequence
      • sorted

        default Sequence<T> sorted()
        Return a sorted Sequence, Sequence element type T should implement Comparable interface. The elements should not be null, or NPE maybe thrown. ClassCastException may be thrown if T not sub type of Comparable
      • forEach

        default void forEach​(java.util.function.Consumer<? super T> consumer)
        Consumer the remained element in this Sequence.
        参数:
        consumer - the consumer
      • peek

        default Sequence<T> peek​(java.util.function.Consumer<? super T> consumer)
        Return a Sequence, with has a side effect when a element is take out, it is consume by specified consumer.
      • reduce

        default <R> R reduce​(R initialValue,
                             java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
        reduce operator
        类型参数:
        R - the result value type
        参数:
        initialValue - the initial value
        reducer - the reducer
        返回:
        a value calculate by reducer
      • collect

        default <R> R collect​(CollectConsumer<? super T,​? extends R> collectConsumer)
        Collect elements to collection.
        类型参数:
        R - the returned Collection type
        参数:
        collectConsumer - to create a Collection instance
      • toCollection

        default <R extends java.util.Collection<T>> R toCollection​(java.util.function.Supplier<R> collectionSupplier)
        Collect elements to collection.
        类型参数:
        R - the returned Collection type
        参数:
        collectionSupplier - to create a Collection instance
      • toArrayList

        default java.util.ArrayList<T> toArrayList()
        reduce to array list.
      • toImmutableList

        default java.util.List<T> toImmutableList()
        reduce to immutable List.
      • toHashSet

        default java.util.HashSet<T> toHashSet()
        reduce to hash set
      • toImmutableSet

        default java.util.Set<T> toImmutableSet()
        reduce to immutable Set.
      • toHashMap

        default <K,​V> java.util.HashMap<K,​V> toHashMap​(java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                   java.util.function.Function<? super T,​? extends V> valueMapper)
        reduce to hash map
        类型参数:
        K - map key type
        V - map value type
        参数:
        keyMapper - the mapper to calculate map key
        valueMapper - the mapper to calculate map value
        返回:
        a new map
      • toMap

        default <K,​V,​R extends java.util.Map<K,​V>> R toMap​(java.util.function.Supplier<R> mapSupplier,
                                                                             java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                             java.util.function.Function<? super T,​? extends V> valueMapper)
        collect elements to map
        类型参数:
        K - map key type
        V - map value type
        参数:
        mapSupplier - to get a map instance
        keyMapper - the mapper to calculate map key
        valueMapper - the mapper to calculate map value
        返回:
        a new map
      • toImmutableMap

        default <K,​V> java.util.Map<K,​V> toImmutableMap​(java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                    java.util.function.Function<? super T,​? extends V> valueMapper)
        collect elements to immutable Map.
      • groupAndReduce

        default <K,​R> java.util.Map<K,​R> groupAndReduce​(java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                    java.util.function.Supplier<R> initial,
                                                                    java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
        Group the element by key mapper; for per single key, reduce elements with this key to the result value.
        类型参数:
        K - the group key type
        R - the reduce result type
        参数:
        keyMapper - get key from element
        initial - initial value supplier for reducing
        reducer - reduce function
        返回:
        a map contains grouped result. The is no guaranty for the map's immutability.
      • groupAndCollect

        default <K,​R> java.util.Map<K,​R> groupAndCollect​(java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                     java.util.function.Supplier<? extends CollectConsumer<? super T,​? extends R>> collector)
        Group the element by key mapper; for per single key, collect elements with this key to the result value.
        类型参数:
        K - the group key type
        R - the reduce result type
        参数:
        keyMapper - get key from element
        collector - the collector supplier
        返回:
        a map contains grouped result. The is no guaranty for the map's immutability.
      • groupToCollection

        default <K,​R extends java.util.Collection<T>> java.util.Map<K,​R> groupToCollection​(java.util.function.Function<? super T,​? extends K> keyMapper,
                                                                                                       java.util.function.Supplier<R> collectionSupplier)
        Group the element by key mapper; for per single key, reduce elements with this key to the result value.
        类型参数:
        K - the group key type
        R - the reduce result type
        参数:
        keyMapper - get key from element
        collectionSupplier - supplier to make a Collection instance
        返回:
        a map contains grouped result. The is no guaranty for the map's immutability.
      • groupToList

        default <K> java.util.Map<K,​java.util.List<T>> groupToList​(java.util.function.Function<? super T,​? extends K> keyMapper)
        Group the element by key mapper; for per single key, a immutable list contains all elements with this key is constructed.
        类型参数:
        K - the group key type
        参数:
        keyMapper - get key from element
        返回:
        a map contains grouped result as immutable list. The is no guaranty for the returned map's, or the list's immutability.
      • partitionAndReduce

        default <R> PartitionResult<R> partitionAndReduce​(java.util.function.Predicate<? super T> predicate,
                                                          java.util.function.Supplier<R> initial,
                                                          java.util.function.BiFunction<? super R,​? super T,​? extends R> reducer)
        Partition the elements by predicate, and then do reducer for both Seq of elements.
        类型参数:
        R - the reduce result type
        参数:
        predicate - predicate for partition
        initial - initial value supplier for reducing
        reducer - reduce function
      • partitionAndCollect

        default <R extends java.util.Collection<T>> PartitionResult<R> partitionAndCollect​(java.util.function.Predicate<? super T> predicate,
                                                                                           java.util.function.Supplier<R> supplier)
        Partition the elements by predicate, and then collect elements.
        类型参数:
        R - the collection type
        参数:
        predicate - predicate for partition
        supplier - collection supplier
        返回:
        a PartitionResult contains grouped result
      • partitionToList

        default PartitionResult<java.util.List<T>> partitionToList​(java.util.function.Predicate<? super T> predicate)
        Partition the elements by predicate, and then collect elements to immutable list.
        参数:
        predicate - predicate for partition
        返回:
        a PartitionResult contains grouped result as list. The is no guaranty for the returned lists's immutability.
      • joinTo

        default void joinTo​(java.lang.Appendable appendable,
                            java.lang.CharSequence sep,
                            java.lang.CharSequence prefix,
                            java.lang.CharSequence suffix)
        Join the elements to String out
        参数:
        appendable - the appendable to append str
        sep - the separator string between elements
        prefix - the prefix to prepend before all elements
        suffix - the suffix to append after elements
      • joinToString

        default java.lang.String joinToString​(java.lang.CharSequence sep,
                                              java.lang.CharSequence prefix,
                                              java.lang.CharSequence suffix)
        Join the elements to String
        参数:
        sep - the separator string between elements
        prefix - the prefix to prepend before all elements
        suffix - the suffix to append after elements
      • joinToString

        default java.lang.String joinToString​(java.lang.CharSequence sep)
        Join the elements to String
        参数:
        sep - the separator string between elements
      • count

        default long count()
        return the count of elements
      • maxBy

        default java.util.Optional<T> maxBy​(java.util.Comparator<? super T> comparator)
        Get the max value by comparator. If Sequence has no element, return empty Optional. If T is sub type of Comparable and want to use it's compare impl for comparing, Comparator.naturalOrder() can be passed in.
        参数:
        comparator - the comparator
      • max

        default java.util.Optional<T> max()
        Get the max value by natural order comparator. If Sequence has no element, return empty Optional. Elements in this Sequence should not be null. ClassCastException may be thrown if T not sub type of Comparable
      • minBy

        default java.util.Optional<T> minBy​(java.util.Comparator<? super T> comparator)
        Get the min value by comparator. If Sequence has no element, return empty Optional. If T is sub type of Comparable and want to use it's compare impl for comparing, Comparator.naturalOrder() can be passed in.
        参数:
        comparator - the comparator
      • min

        default java.util.Optional<T> min()
        Get the min value by natural order comparator. If Sequence has no element, return empty Optional. Elements in this Sequence should not be null. ClassCastException may be thrown if T not sub type of Comparable
      • sumInt

        default int sumInt​(java.util.function.ToIntFunction<T> function)
        Sum the int values calculated by the elements.
        参数:
        function - the function convert elements to int values
      • sumLong

        default long sumLong​(java.util.function.ToLongFunction<T> function)
        Sum the long values calculated by the elements.
        参数:
        function - the function convert elements to long values
      • sumDouble

        default double sumDouble​(java.util.function.ToDoubleFunction<T> function)
        Sum the double values calculated by the elements.
        参数:
        function - the function convert elements to double values
      • averageLong

        default double averageLong​(java.util.function.ToLongFunction<T> function)
        Calculate the average value of values calculated by the elements.
        参数:
        function - the function convert elements to long values
      • averageDouble

        default double averageDouble​(java.util.function.ToDoubleFunction<T> function)
        Calculate the average value of values calculated by the elements.
        参数:
        function - the function convert elements to double float values
      • first

        default java.util.Optional<T> first()
        Return the first element of Sequence. If sequence is empty, return empty Optional. The element in sequence should not be null.
      • last

        default java.util.Optional<T> last()
        Return the last element of Sequence. If sequence is empty, return empty Optional. The element in sequence should not be null.
      • find

        default java.util.Optional<T> find​(java.util.function.Predicate<? super T> predicate)
        Find and return the first element meet the predicate in Sequence. If none is found, return empty Optional. The element in sequence should not be null.
      • findLast

        default java.util.Optional<T> findLast​(java.util.function.Predicate<? super T> predicate)
        Find and return the lat element meet the predicate in Sequence. If none is found, return empty Optional. The element in sequence should not be null.
      • anyMatch

        default boolean anyMatch​(java.util.function.Predicate<? super T> predicate)
        If any element in this sequence meet the predicate. This method would always return false if Sequence is empty.
      • allMatch

        default boolean allMatch​(java.util.function.Predicate<? super T> predicate)
        If all elements in this sequence meet the predicate. This method would always return true if Sequence is empty.
      • noneMatch

        default boolean noneMatch​(java.util.function.Predicate<? super T> predicate)
        If no elements in this sequence meet the predicate. This method would always return true if Sequence is empty.
      • asIterable

        default java.lang.Iterable<T> asIterable()
        Return a iterable that wrap this sequence, and can iterate only once.
      • asStream

        default java.util.stream.Stream<T> asStream()
        Return a Stream that wrap this sequence.