Interface RemoteStream<T>

Type Parameters:
T - the type of the stream elements
All Superinterfaces:
AutoCloseable, BaseRemoteStream<T,Stream<T>>, BaseStream<T,Stream<T>>, Stream<T>

public interface RemoteStream<T> extends Stream<T>, BaseRemoteStream<T,Stream<T>>
This interface is an extension of java.util.stream.Stream that captures lambdas used as method arguments as serializable lambdas.
Since:
12.2.1
Author:
as 2014.08.11
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.stream.Stream

    Stream.Builder<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    allMatch(Remote.Predicate<? super T> predicate)
    Returns whether all elements of this stream match the provided predicate.
    boolean
    allMatch(Predicate<? super T> predicate)
    Returns whether all elements of this stream match the provided predicate.
    default boolean
    anyMatch(Remote.Predicate<? super T> predicate)
    Returns whether any elements of this stream match the provided predicate.
    boolean
    anyMatch(Predicate<? super T> predicate)
    Returns whether any elements of this stream match the provided predicate.
    default <R> R
    collect(Remote.Supplier<R> supplier, Remote.BiConsumer<R,? super T> accumulator, Remote.BiConsumer<R,R> combiner)
    Performs a mutable reduction operation on the elements of this stream.
    <R, A> R
    collect(RemoteCollector<? super T,A,R> collector)
    Performs a mutable reduction operation on the elements of this stream using a Collector.
    <R> R
    collect(Supplier<R> supplier, BiConsumer<R,? super T> accumulator, BiConsumer<R,R> combiner)
    Performs a mutable reduction operation on the elements of this stream.
    default <R, A> R
    collect(Collector<? super T,A,R> collector)
    Performs a mutable reduction operation on the elements of this stream using a Collector.
    long
    Returns the count of elements in this stream.
    Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream.
    default Stream<T>
    dropWhile(Predicate<? super T> predicate)
    Returns, if this stream is ordered, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate.
    static <K, V> RemoteStream<InvocableMap.Entry<K,V>>
    Create a RemoteStream of specified map's entries.
    default RemoteStream<T>
    filter(Remote.Predicate<? super T> predicate)
    Returns a stream consisting of the elements of this stream that match the given predicate.
    filter(Predicate<? super T> predicate)
    Returns a stream consisting of the elements of this stream that match the given predicate.
    Returns an Optional describing some element of the stream, or an empty Optional if the stream is empty.
    Returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty.
    default <R> RemoteStream<R>
    flatMap(Remote.Function<? super T,? extends Stream<? extends R>> mapper)
    Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    <R> RemoteStream<R>
    flatMap(Function<? super T,? extends Stream<? extends R>> mapper)
    Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToDouble(Remote.Function<? super T,? extends DoubleStream> mapper)
    Returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToDouble(Function<? super T,? extends DoubleStream> mapper)
    Returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToInt(Remote.Function<? super T,? extends IntStream> mapper)
    Returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToInt(Function<? super T,? extends IntStream> mapper)
    Returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToLong(Remote.Function<? super T,? extends LongStream> mapper)
    Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    flatMapToLong(Function<? super T,? extends LongStream> mapper)
    Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element.
    void
    forEach(Consumer<? super T> action)
    Performs an action for each element of this stream.
    void
    forEachOrdered(Consumer<? super T> action)
    Performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.
    static <K, V> RemoteStream<K>
    keySet(InvocableMap<K,V> map)
    Create a RemoteStream of specified map's keys.
    limit(long maxSize)
    Returns a stream consisting of the elements of this stream, truncated to be no longer than maxSize in length.
    default <R> RemoteStream<R>
    map(Remote.Function<? super T,? extends R> mapper)
    Returns a stream consisting of the results of applying the given function to the elements of this stream.
    default <R> RemoteStream<R>
    map(ValueExtractor<? super T,? extends R> mapper)
    Returns a stream consisting of the results of applying the given extractor to the elements of this stream.
    <R> RemoteStream<R>
    map(Function<? super T,? extends R> mapper)
    Returns a stream consisting of the results of applying the given function to the elements of this stream.
    default <R> RemoteStream<R>
    mapMulti(Remote.BiConsumer<? super T,? super Consumer<R>> mapper)
    Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    <R> RemoteStream<R>
    mapMulti(BiConsumer<? super T,? super Consumer<R>> mapper)
    Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    Returns a DoubleStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    mapMultiToDouble(BiConsumer<? super T,? super DoubleConsumer> mapper)
    Returns a DoubleStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    mapMultiToInt(Remote.BiConsumer<? super T,? super IntConsumer> mapper)
    Returns an IntStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    mapMultiToInt(BiConsumer<? super T,? super IntConsumer> mapper)
    Returns an IntStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    Returns a LongStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    mapMultiToLong(BiConsumer<? super T,? super LongConsumer> mapper)
    Returns a LongStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements.
    Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
    mapToDouble(ValueExtractor<? super T,? extends Number> mapper)
    Returns an DoubleStream consisting of the results of applying the given extractor to the elements of this stream.
    mapToDouble(ToDoubleFunction<? super T> mapper)
    Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
    mapToInt(Remote.ToIntFunction<? super T> mapper)
    Returns an IntStream consisting of the results of applying the given function to the elements of this stream.
    mapToInt(ValueExtractor<? super T,? extends Number> mapper)
    Returns an IntStream consisting of the results of applying the given extractor to the elements of this stream.
    mapToInt(ToIntFunction<? super T> mapper)
    Returns an IntStream consisting of the results of applying the given function to the elements of this stream.
    Returns a LongStream consisting of the results of applying the given function to the elements of this stream.
    mapToLong(ValueExtractor<? super T,? extends Number> mapper)
    Returns an LongStream consisting of the results of applying the given extractor to the elements of this stream.
    mapToLong(ToLongFunction<? super T> mapper)
    Returns a LongStream consisting of the results of applying the given function to the elements of this stream.
    default Optional<T>
    max(Remote.Comparator<? super T> comparator)
    Returns the maximum element of this stream according to the provided Comparator.
    default <U> Optional<T>
    max(ValueExtractor<? super U,? extends Comparable> extractor)
    Returns the maximum element of this stream according to the attribute extracted by the provided ValueExtractor.
    max(Comparator<? super T> comparator)
    Returns the maximum element of this stream according to the provided Comparator.
    default Optional<T>
    min(Remote.Comparator<? super T> comparator)
    Returns the minimum element of this stream according to the provided Comparator.
    default <U> Optional<T>
    min(ValueExtractor<? super U,? extends Comparable> extractor)
    Returns the minimum element of this stream according to the attribute extracted by the provided ValueExtractor.
    min(Comparator<? super T> comparator)
    Returns the minimum element of this stream according to the provided Comparator.
    default boolean
    noneMatch(Remote.Predicate<? super T> predicate)
    Returns whether no elements of this stream match the provided predicate.
    boolean
    noneMatch(Predicate<? super T> predicate)
    Returns whether no elements of this stream match the provided predicate.
    Returns an equivalent stream that is parallel.
    default RemoteStream<T>
    peek(Remote.Consumer<? super T> action)
    Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.
    peek(Consumer<? super T> action)
    Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.
    default Optional<T>
    Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.
    reduce(BinaryOperator<T> accumulator)
    Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.
    default T
    reduce(T identity, Remote.BinaryOperator<T> accumulator)
    Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.
    reduce(T identity, BinaryOperator<T> accumulator)
    Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value.
    default <U> U
    reduce(U identity, Remote.BiFunction<U,? super T,U> accumulator, Remote.BinaryOperator<U> combiner)
    Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions.
    <U> U
    reduce(U identity, BiFunction<U,? super T,U> accumulator, BinaryOperator<U> combiner)
    Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions.
    Returns an equivalent stream that is sequential.
    skip(long n)
    Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream.
    Returns a stream consisting of the elements of this stream, sorted according to natural order.
    default RemoteStream<T>
    sorted(Remote.Comparator<? super T> comparator)
    Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.
    default RemoteStream<T>
    sorted(Remote.Comparator<? super T> comparator, boolean fInverse)
    Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.
    default <U> RemoteStream<T>
    sorted(ValueExtractor<? super U,? extends Comparable> extractor)
    Returns a stream consisting of the elements of this stream, sorted according to attribute extracted by the provided ValueExtractor.
    default <U> RemoteStream<T>
    sorted(ValueExtractor<? super U,? extends Comparable> extractor, boolean fInverse)
    Returns a stream consisting of the elements of this stream, sorted according to attribute extracted by the provided ValueExtractor.
    sorted(Comparator<? super T> comparator)
    Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.
    default Stream<T>
    takeWhile(Predicate<? super T> predicate)
    Returns, if this stream is ordered, a stream consisting of the longest prefix of elements taken from this stream that match the given predicate.
    Returns an array containing the elements of this stream.
    <A> A[]
    toArray(IntFunction<A[]> generator)
    Returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.
    static <T extends Number>
    RemoteDoubleStream
    Convert stream of numbers into RemoteDoubleStream.
    static <T extends Number>
    RemoteIntStream
    Convert stream of numbers into RemoteIntStream.
    default List<T>
    Accumulates the elements of this stream into a List.
    static <T extends Number>
    RemoteLongStream
    Convert stream of numbers into RemoteLongStream.
    Returns an equivalent stream that is unordered.
    static <K, V> RemoteStream<V>
    values(InvocableMap<K,V> map)
    Create a RemoteStream of specified map's values.

    Methods inherited from interface com.tangosol.util.stream.BaseRemoteStream

    pipeline

    Methods inherited from interface java.util.stream.BaseStream

    close, isParallel, iterator, onClose, spliterator
  • Method Details

    • entrySet

      static <K, V> RemoteStream<InvocableMap.Entry<K,V>> entrySet(InvocableMap<K,V> map)
      Create a RemoteStream of specified map's entries.
      Type Parameters:
      K - the type of map keys
      V - the type of map values
      Parameters:
      map - the map to create a remote stream for
      Returns:
      a RemoteStream of specified map's entries
    • keySet

      static <K, V> RemoteStream<K> keySet(InvocableMap<K,V> map)
      Create a RemoteStream of specified map's keys.
      Type Parameters:
      K - the type of map keys
      V - the type of map values
      Parameters:
      map - the map to create a remote stream for
      Returns:
      a RemoteStream of specified map's keys
    • values

      static <K, V> RemoteStream<V> values(InvocableMap<K,V> map)
      Create a RemoteStream of specified map's values.
      Type Parameters:
      K - the type of map keys
      V - the type of map values
      Parameters:
      map - the map to create a remote stream for
      Returns:
      a RemoteStream of specified map's values
    • sequential

      RemoteStream<T> sequential()
      Returns an equivalent stream that is sequential. May return itself, either because the stream was already sequential, or because the underlying stream state was modified to be sequential.

      This is an intermediate operation.

      Specified by:
      sequential in interface BaseStream<T,Stream<T>>
      Returns:
      a sequential stream
    • parallel

      RemoteStream<T> parallel()
      Returns an equivalent stream that is parallel. May return itself, either because the stream was already parallel, or because the underlying stream state was modified to be parallel.

      This is an intermediate operation.

      Specified by:
      parallel in interface BaseStream<T,Stream<T>>
      Returns:
      a parallel stream
    • unordered

      RemoteStream<T> unordered()
      Returns an equivalent stream that is unordered. May return itself, either because the stream was already unordered, or because the underlying stream state670G was modified to be unordered.

      This is an intermediate operation.

      Specified by:
      unordered in interface BaseStream<T,Stream<T>>
      Returns:
      an unordered stream
    • filter

      RemoteStream<T> filter(Predicate<? super T> predicate)
      Returns a stream consisting of the elements of this stream that match the given predicate.

      This is an intermediate operation.

      Specified by:
      filter in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be included
      Returns:
      the new stream
    • filter

      default RemoteStream<T> filter(Remote.Predicate<? super T> predicate)
      Returns a stream consisting of the elements of this stream that match the given predicate.

      This is an intermediate operation.

      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each element to determine if it should be included
      Returns:
      the new stream
    • map

      <R> RemoteStream<R> map(Function<? super T,? extends R> mapper)
      Returns a stream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Specified by:
      map in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • map

      default <R> RemoteStream<R> map(Remote.Function<? super T,? extends R> mapper)
      Returns a stream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Type Parameters:
      R - the type of resulting stream elements
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • map

      default <R> RemoteStream<R> map(ValueExtractor<? super T,? extends R> mapper)
      Returns a stream consisting of the results of applying the given extractor to the elements of this stream.

      This is an intermediate operation.

      Type Parameters:
      R - the type of resulting stream elements
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToInt

      RemoteIntStream mapToInt(ToIntFunction<? super T> mapper)
      Returns an IntStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Specified by:
      mapToInt in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToInt

      default RemoteIntStream mapToInt(Remote.ToIntFunction<? super T> mapper)
      Returns an IntStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToInt

      default RemoteIntStream mapToInt(ValueExtractor<? super T,? extends Number> mapper)
      Returns an IntStream consisting of the results of applying the given extractor to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToLong

      RemoteLongStream mapToLong(ToLongFunction<? super T> mapper)
      Returns a LongStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Specified by:
      mapToLong in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToLong

      default RemoteLongStream mapToLong(Remote.ToLongFunction<? super T> mapper)
      Returns a LongStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToLong

      default RemoteLongStream mapToLong(ValueExtractor<? super T,? extends Number> mapper)
      Returns an LongStream consisting of the results of applying the given extractor to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToDouble

      RemoteDoubleStream mapToDouble(ToDoubleFunction<? super T> mapper)
      Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Specified by:
      mapToDouble in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToDouble

      default RemoteDoubleStream mapToDouble(Remote.ToDoubleFunction<? super T> mapper)
      Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • mapToDouble

      default RemoteDoubleStream mapToDouble(ValueExtractor<? super T,? extends Number> mapper)
      Returns an DoubleStream consisting of the results of applying the given extractor to the elements of this stream.

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element
      Returns:
      the new stream
    • flatMap

      <R> RemoteStream<R> flatMap(Function<? super T,? extends Stream<? extends R>> mapper)
      Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Specified by:
      flatMap in interface Stream<T>
      Type Parameters:
      R - The element type of the new stream
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
    • flatMap

      default <R> RemoteStream<R> flatMap(Remote.Function<? super T,? extends Stream<? extends R>> mapper)
      Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Type Parameters:
      R - The element type of the new stream
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
    • flatMapToInt

      RemoteIntStream flatMapToInt(Function<? super T,? extends IntStream> mapper)
      Returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Specified by:
      flatMapToInt in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • flatMapToInt

      default RemoteIntStream flatMapToInt(Remote.Function<? super T,? extends IntStream> mapper)
      Returns an IntStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • flatMapToLong

      RemoteLongStream flatMapToLong(Function<? super T,? extends LongStream> mapper)
      Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Specified by:
      flatMapToLong in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • flatMapToLong

      default RemoteLongStream flatMapToLong(Remote.Function<? super T,? extends LongStream> mapper)
      Returns an LongStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • flatMapToDouble

      RemoteDoubleStream flatMapToDouble(Function<? super T,? extends DoubleStream> mapper)
      Returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Specified by:
      flatMapToDouble in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • flatMapToDouble

      default RemoteDoubleStream flatMapToDouble(Remote.Function<? super T,? extends DoubleStream> mapper)
      Returns an DoubleStream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. Each mapped stream is closed after its contents have been placed into this stream. (If a mapped stream is null an empty stream is used, instead.)

      This is an intermediate operation.

      Parameters:
      mapper - a non-interfering, stateless function to apply to each element which produces a stream of new values
      Returns:
      the new stream
      See Also:
    • mapMulti

      <R> RemoteStream<R> mapMulti(BiConsumer<? super T,? super Consumer<R>> mapper)
      Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Specified by:
      mapMulti in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMulti

      default <R> RemoteStream<R> mapMulti(Remote.BiConsumer<? super T,? super Consumer<R>> mapper)
      Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToInt

      RemoteIntStream mapMultiToInt(BiConsumer<? super T,? super IntConsumer> mapper)
      Returns an IntStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Specified by:
      mapMultiToInt in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToInt

      default RemoteIntStream mapMultiToInt(Remote.BiConsumer<? super T,? super IntConsumer> mapper)
      Returns an IntStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToLong

      RemoteLongStream mapMultiToLong(BiConsumer<? super T,? super LongConsumer> mapper)
      Returns a LongStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Specified by:
      mapMultiToLong in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToLong

      default RemoteLongStream mapMultiToLong(Remote.BiConsumer<? super T,? super LongConsumer> mapper)
      Returns a LongStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToDouble

      RemoteDoubleStream mapMultiToDouble(BiConsumer<? super T,? super DoubleConsumer> mapper)
      Returns a DoubleStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Specified by:
      mapMultiToDouble in interface Stream<T>
      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • mapMultiToDouble

      default RemoteDoubleStream mapMultiToDouble(Remote.BiConsumer<? super T,? super DoubleConsumer> mapper)
      Returns a DoubleStream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. Replacement is performed by applying the provided mapping function to each element in conjunction with a consumer argument that accepts replacement elements. The mapping function calls the consumer zero or more times to provide the replacement elements.

      This is an intermediate operation.

      If the consumer argument is used outside the scope of its application to the mapping function, the results are undefined.

      Parameters:
      mapper - a non-interfering, stateless function that generates replacement elements
      Returns:
      the new stream
      Since:
      22.09
    • peek

      RemoteStream<T> peek(Consumer<? super T> action)
      Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.

      This is an intermediate operation.

      For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.

      Specified by:
      peek in interface Stream<T>
      Parameters:
      action - a non-interfering action to perform on the elements as they are consumed from the stream
      Returns:
      the new stream
    • peek

      default RemoteStream<T> peek(Remote.Consumer<? super T> action)
      Returns a stream consisting of the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.

      This is an intermediate operation.

      For parallel stream pipelines, the action may be called at whatever time and in whatever thread the element is made available by the upstream operation. If the action modifies shared state, it is responsible for providing the required synchronization.

      Parameters:
      action - a non-interfering action to perform on the elements as they are consumed from the stream
      Returns:
      the new stream
    • limit

      Stream<T> limit(long maxSize)
      Returns a stream consisting of the elements of this stream, truncated to be no longer than maxSize in length.

      This is a short-circuiting stateful intermediate operation.

      Specified by:
      limit in interface Stream<T>
      Parameters:
      maxSize - the number of elements the stream should be limited to
      Returns:
      the new stream
      Throws:
      IllegalArgumentException - if maxSize is negative
    • skip

      Stream<T> skip(long n)
      Returns a stream consisting of the remaining elements of this stream after discarding the first n elements of the stream. If this stream contains fewer than n elements then an empty stream will be returned.

      This is a stateful intermediate operation.

      Specified by:
      skip in interface Stream<T>
      Parameters:
      n - the number of leading elements to skip
      Returns:
      the new stream
      Throws:
      IllegalArgumentException - if n is negative
    • takeWhile

      default Stream<T> takeWhile(Predicate<? super T> predicate)
      Returns, if this stream is ordered, a stream consisting of the longest prefix of elements taken from this stream that match the given predicate. Otherwise returns, if this stream is unordered, a stream consisting of a subset of elements taken from this stream that match the given predicate.

      If this stream is ordered then the longest prefix is a contiguous sequence of elements of this stream that match the given predicate. The first element of the sequence is the first element of this stream, and the element immediately following the last element of the sequence does not match the given predicate.

      If this stream is unordered, and some (but not all) elements of this stream match the given predicate, then the behavior of this operation is nondeterministic; it is free to take any subset of matching elements (which includes the empty set).

      Independent of whether this stream is ordered or unordered if all elements of this stream match the given predicate then this operation takes all elements (the result is the same as the input), or if no elements of the stream match the given predicate then no elements are taken (the result is an empty stream).

      This is a short-circuiting stateful intermediate operation.

      Specified by:
      takeWhile in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.
      Returns:
      the new stream
      Since:
      9
      API Note:
      While takeWhile() is generally a cheap operation on sequential stream pipelines, it can be quite expensive on ordered parallel pipelines, since the operation is constrained to return not just any valid prefix, but the longest prefix of elements in the encounter order. Using an unordered stream source (such as Stream.generate(Supplier)) or removing the ordering constraint with unordered() may result in significant speedups of takeWhile() in parallel pipelines, if the semantics of your situation permit. If consistency with encounter order is required, and you are experiencing poor performance or memory utilization with takeWhile() in parallel pipelines, switching to sequential execution with sequential() may improve performance.
      Implementation Requirements:
      The default implementation obtains the spliterator of this stream, wraps that spliterator so as to support the semantics of this operation on traversal, and returns a new stream associated with the wrapped spliterator. The returned stream preserves the execution characteristics of this stream (namely parallel or sequential execution as per BaseStream.isParallel()) but the wrapped spliterator may choose to not support splitting. When the returned stream is closed, the close handlers for both the returned and this stream are invoked.
    • dropWhile

      default Stream<T> dropWhile(Predicate<? super T> predicate)
      Returns, if this stream is ordered, a stream consisting of the remaining elements of this stream after dropping the longest prefix of elements that match the given predicate. Otherwise returns, if this stream is unordered, a stream consisting of the remaining elements of this stream after dropping a subset of elements that match the given predicate.

      If this stream is ordered then the longest prefix is a contiguous sequence of elements of this stream that match the given predicate. The first element of the sequence is the first element of this stream, and the element immediately following the last element of the sequence does not match the given predicate.

      If this stream is unordered, and some (but not all) elements of this stream match the given predicate, then the behavior of this operation is nondeterministic; it is free to drop any subset of matching elements (which includes the empty set).

      Independent of whether this stream is ordered or unordered if all elements of this stream match the given predicate then this operation drops all elements (the result is an empty stream), or if no elements of the stream match the given predicate then no elements are dropped (the result is the same as the input).

      This is a stateful intermediate operation.

      Specified by:
      dropWhile in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements to determine the longest prefix of elements.
      Returns:
      the new stream
      Since:
      9
      API Note:
      While dropWhile() is generally a cheap operation on sequential stream pipelines, it can be quite expensive on ordered parallel pipelines, since the operation is constrained to return not just any valid prefix, but the longest prefix of elements in the encounter order. Using an unordered stream source (such as Stream.generate(Supplier)) or removing the ordering constraint with unordered() may result in significant speedups of dropWhile() in parallel pipelines, if the semantics of your situation permit. If consistency with encounter order is required, and you are experiencing poor performance or memory utilization with dropWhile() in parallel pipelines, switching to sequential execution with sequential() may improve performance.
      Implementation Requirements:
      The default implementation obtains the spliterator of this stream, wraps that spliterator so as to support the semantics of this operation on traversal, and returns a new stream associated with the wrapped spliterator. The returned stream preserves the execution characteristics of this stream (namely parallel or sequential execution as per BaseStream.isParallel()) but the wrapped spliterator may choose to not support splitting. When the returned stream is closed, the close handlers for both the returned and this stream are invoked.
    • distinct

      Stream<T> distinct()
      Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream.

      For ordered streams, the selection of distinct elements is stable (for duplicated elements, the element appearing first in the encounter order is preserved.) For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Specified by:
      distinct in interface Stream<T>
      Returns:
      the new stream
    • sorted

      RemoteStream<T> sorted()
      Returns a stream consisting of the elements of this stream, sorted according to natural order. If the elements of this stream are not Comparable, a java.lang.ClassCastException may be thrown when the terminal operation is executed.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Specified by:
      sorted in interface Stream<T>
      Returns:
      the new stream
    • sorted

      RemoteStream<T> sorted(Comparator<? super T> comparator)
      Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Specified by:
      sorted in interface Stream<T>
      Parameters:
      comparator - a non-interfering, stateless Comparator to be used to compare stream elements
      Returns:
      the new stream
    • sorted

      default RemoteStream<T> sorted(Remote.Comparator<? super T> comparator)
      Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Parameters:
      comparator - a non-interfering, stateless Comparator to be used to compare stream elements
      Returns:
      the new stream
    • sorted

      default RemoteStream<T> sorted(Remote.Comparator<? super T> comparator, boolean fInverse)
      Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Parameters:
      comparator - a non-interfering, stateless Comparator to be used to compare stream elements
      fInverse - a flag specifying whether to invert the sort order
      Returns:
      the new stream
    • sorted

      default <U> RemoteStream<T> sorted(ValueExtractor<? super U,? extends Comparable> extractor)
      Returns a stream consisting of the elements of this stream, sorted according to attribute extracted by the provided ValueExtractor.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Type Parameters:
      U - a super type of the value to extract from
      Parameters:
      extractor - a non-interfering, stateless ValueExtractor to be used to extract the attribute that should be used to compare stream elements
      Returns:
      the new stream
    • sorted

      default <U> RemoteStream<T> sorted(ValueExtractor<? super U,? extends Comparable> extractor, boolean fInverse)
      Returns a stream consisting of the elements of this stream, sorted according to attribute extracted by the provided ValueExtractor.

      For ordered streams, the sort is stable. For unordered streams, no stability guarantees are made.

      This is a stateful intermediate operation.

      Type Parameters:
      U - the super type of value to extract from
      Parameters:
      extractor - a non-interfering, stateless ValueExtractor to be used to extract the attribute that should be used to compare stream elements
      fInverse - a flag specifying whether to invert natural sort order
      Returns:
      the new stream
    • forEach

      void forEach(Consumer<? super T> action)
      Performs an action for each element of this stream.

      This is a terminal operation.

      Specified by:
      forEach in interface Stream<T>
      Parameters:
      action - a non-interfering action to perform on the elements
    • forEachOrdered

      void forEachOrdered(Consumer<? super T> action)
      Performs an action for each element of this stream, in the encounter order of the stream if the stream has a defined encounter order.

      This is a terminal operation.

      This operation processes the elements one at a time, in encounter order if one exists. Performing the action for one element happens-before performing the action for subsequent elements, but for any given element, the action may be performed in whatever thread the library chooses.

      Specified by:
      forEachOrdered in interface Stream<T>
      Parameters:
      action - a non-interfering action to perform on the elements
      See Also:
    • toArray

      Object[] toArray()
      Returns an array containing the elements of this stream.

      This is a terminal operation.

      Specified by:
      toArray in interface Stream<T>
      Returns:
      an array containing the elements of this stream
    • toArray

      <A> A[] toArray(IntFunction<A[]> generator)
      Returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.

      This is a terminal operation.

      Specified by:
      toArray in interface Stream<T>
      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 stream
      Throws:
      ArrayStoreException - if the runtime type of the array returned from the array generator is not a supertype of the runtime type of every element in this stream
    • reduce

      T reduce(T identity, BinaryOperator<T> accumulator)
      Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value. This is equivalent to:
      
           T result = identity;
           for (T element : this stream)
               result = accumulator.apply(result, element)
           return result;
       

      but is not constrained to execute sequentially.

      The identity value must be an identity for the accumulator function. This means that for all t, accumulator.apply(identity, t) is equal to t. The accumulator function must be an associative function.

      This is a terminal operation.

      Specified by:
      reduce in interface Stream<T>
      Parameters:
      identity - the identity value for the accumulating function
      accumulator - an associative, non-interfering, stateless function for combining two values
      Returns:
      the result of the reduction
    • reduce

      default T reduce(T identity, Remote.BinaryOperator<T> accumulator)
      Performs a reduction on the elements of this stream, using the provided identity value and an associative accumulation function, and returns the reduced value. This is equivalent to:
      
           T result = identity;
           for (T element : this stream)
               result = accumulator.apply(result, element)
           return result;
       

      but is not constrained to execute sequentially.

      The identity value must be an identity for the accumulator function. This means that for all t, accumulator.apply(identity, t) is equal to t. The accumulator function must be an associative function.

      This is a terminal operation.

      Parameters:
      identity - the identity value for the accumulating function
      accumulator - an associative, non-interfering, stateless function for combining two values
      Returns:
      the result of the reduction
    • reduce

      Optional<T> reduce(BinaryOperator<T> accumulator)
      Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any. This is equivalent to:
      
           boolean foundAny = false;
           T result = null;
           for (T element : this stream) {
               if (!foundAny) {
                   foundAny = true;
                   result = element;
               }
               else
                   result = accumulator.apply(result, element);
           }
           return foundAny ? Optional.of(result) : Optional.empty();
       

      but is not constrained to execute sequentially.

      The accumulator function must be an associative function.

      This is a terminal operation.

      Specified by:
      reduce in interface Stream<T>
      Parameters:
      accumulator - an associative, non-interfering, stateless function for combining two values
      Returns:
      an Optional describing the result of the reduction
      Throws:
      NullPointerException - if the result of the reduction is null
      See Also:
    • reduce

      default Optional<T> reduce(Remote.BinaryOperator<T> accumulator)
      Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any. This is equivalent to:
      
           boolean foundAny = false;
           T result = null;
           for (T element : this stream) {
               if (!foundAny) {
                   foundAny = true;
                   result = element;
               }
               else
                   result = accumulator.apply(result, element);
           }
           return foundAny ? Optional.of(result) : Optional.empty();
       

      but is not constrained to execute sequentially.

      The accumulator function must be an associative function.

      This is a terminal operation.

      Parameters:
      accumulator - an associative, non-interfering, stateless function for combining two values
      Returns:
      an Optional describing the result of the reduction
      Throws:
      NullPointerException - if the result of the reduction is null
      See Also:
    • reduce

      <U> U reduce(U identity, BiFunction<U,? super T,U> accumulator, BinaryOperator<U> combiner)
      Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions. This is equivalent to:
      
           U result = identity;
           for (T element : this stream)
               result = accumulator.apply(result, element)
           return result;
       

      but is not constrained to execute sequentially.

      The identity value must be an identity for the combiner function. This means that for all u, combiner(identity, u) is equal to u. Additionally, the combiner function must be compatible with the accumulator function; for all u and t, the following must hold:

      
           combiner.apply(u, accumulator.apply(identity, t)) ==
       accumulator.apply(u, t)
       

      This is a terminal operation.

      Specified by:
      reduce in interface Stream<T>
      Parameters:
      identity - the identity value for the combiner function
      accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result
      combiner - an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
      Returns:
      the result of the reduction
      See Also:
    • reduce

      default <U> U reduce(U identity, Remote.BiFunction<U,? super T,U> accumulator, Remote.BinaryOperator<U> combiner)
      Performs a reduction on the elements of this stream, using the provided identity, accumulation and combining functions. This is equivalent to:
      
           U result = identity;
           for (T element : this stream)
               result = accumulator.apply(result, element)
           return result;
       

      but is not constrained to execute sequentially.

      The identity value must be an identity for the combiner function. This means that for all u, combiner(identity, u) is equal to u. Additionally, the combiner function must be compatible with the accumulator function; for all u and t, the following must hold:

      
           combiner.apply(u, accumulator.apply(identity, t)) ==
       accumulator.apply(u, t)
       

      This is a terminal operation.

      Type Parameters:
      U - the type of stream elements
      Parameters:
      identity - the identity value for the combiner function
      accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result
      combiner - an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
      Returns:
      the result of the reduction
      See Also:
    • collect

      <R> R collect(Supplier<R> supplier, BiConsumer<R,? super T> accumulator, BiConsumer<R,R> combiner)
      Performs a mutable reduction operation on the elements of this stream. A mutable reduction is one in which the reduced value is a mutable result container, such as an ArrayList, and elements are incorporated by updating the state of the result rather than by replacing the result. This produces a result equivalent to:
      
           R result = supplier.get();
           for (T element : this stream)
               accumulator.accept(result, element);
           return result;
       

      Like reduce(Object, Remote.BinaryOperator), collect operations can be parallelized without requiring additional synchronization.

      This is a terminal operation.

      Specified by:
      collect in interface Stream<T>
      Parameters:
      supplier - a function that creates a new result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.
      accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result
      combiner - an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
      Returns:
      the result of the reduction
    • collect

      default <R> R collect(Remote.Supplier<R> supplier, Remote.BiConsumer<R,? super T> accumulator, Remote.BiConsumer<R,R> combiner)
      Performs a mutable reduction operation on the elements of this stream. A mutable reduction is one in which the reduced value is a mutable result container, such as an ArrayList, and elements are incorporated by updating the state of the result rather than by replacing the result. This produces a result equivalent to:
      
           R result = supplier.get();
           for (T element : this stream)
               accumulator.accept(result, element);
           return result;
       

      Like reduce(Object, Remote.BinaryOperator), collect operations can be parallelized without requiring additional synchronization.

      This is a terminal operation.

      Type Parameters:
      R - the result type
      Parameters:
      supplier - a function that creates a new result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.
      accumulator - an associative, non-interfering, stateless function for incorporating an additional element into a result
      combiner - an associative, non-interfering, stateless function for combining two values, which must be compatible with the accumulator function
      Returns:
      the result of the reduction
    • collect

      default <R, A> R collect(Collector<? super T,A,R> collector)
      Performs a mutable reduction operation on the elements of this stream using a Collector. A Collector encapsulates the functions used as arguments to collect(Remote.Supplier, Remote.BiConsumer, Remote.BiConsumer), allowing for reuse of collection strategies and composition of collect operations such as multiple-level grouping or partitioning.

      If the stream is parallel, and the Collector is concurrent, and either the stream is unordered or the collector is unordered, then a concurrent reduction will be performed (see RemoteCollector for details on concurrent reduction.)

      This is a terminal operation.

      Specified by:
      collect in interface Stream<T>
      Parameters:
      collector - the Collector describing the reduction
      Returns:
      the result of the reduction
      See Also:
    • collect

      <R, A> R collect(RemoteCollector<? super T,A,R> collector)
      Performs a mutable reduction operation on the elements of this stream using a Collector. A Collector encapsulates the functions used as arguments to collect(Remote.Supplier, Remote.BiConsumer, Remote.BiConsumer), allowing for reuse of collection strategies and composition of collect operations such as multiple-level grouping or partitioning.

      If the stream is parallel, and the Collector is concurrent, and either the stream is unordered or the collector is unordered, then a concurrent reduction will be performed (see RemoteCollector for details on concurrent reduction.)

      This is a terminal operation.

      Type Parameters:
      R - the type of the result
      A - the intermediate accumulation type of the Collector
      Parameters:
      collector - the Collector describing the reduction
      Returns:
      the result of the reduction
      See Also:
    • toList

      default List<T> toList()
      Accumulates the elements of this stream into a List. The elements in the list will be in this stream's encounter order, if one exists. The returned List is unmodifiable; calls to any mutator method will always cause UnsupportedOperationException to be thrown. There are no guarantees on the implementation type or serializability of the returned List.

      The returned instance may be value-based. Callers should make no assumptions about the identity of the returned instances. Identity-sensitive operations on these instances (reference equality (==), identity hash code, and synchronization) are unreliable and should be avoided.

      This is a terminal operation.

      Specified by:
      toList in interface Stream<T>
      Returns:
      a List containing the stream elements
      Since:
      22.09
    • min

      Optional<T> min(Comparator<? super T> comparator)
      Returns the minimum element of this stream according to the provided Comparator. This is a special case of a reduction.

      This is a terminal operation.

      Specified by:
      min in interface Stream<T>
      Parameters:
      comparator - a non-interfering, stateless Comparator to compare elements of this stream
      Returns:
      an Optional describing the minimum element of this stream, or an empty Optional if the stream is empty
    • min

      default Optional<T> min(Remote.Comparator<? super T> comparator)
      Returns the minimum element of this stream according to the provided Comparator. This is a special case of a reduction.

      This is a terminal operation.

      Parameters:
      comparator - a non-interfering, stateless Comparator to compare elements of this stream
      Returns:
      an Optional describing the minimum element of this stream, or an empty Optional if the stream is empty
    • min

      default <U> Optional<T> min(ValueExtractor<? super U,? extends Comparable> extractor)
      Returns the minimum element of this stream according to the attribute extracted by the provided ValueExtractor. This is a special case of a reduction.

      This is a terminal operation.

      Type Parameters:
      U - a super type of the value to extract from
      Parameters:
      extractor - a non-interfering, stateless ValueExtractor to be used to extract the attribute that should be used to compare stream elements
      Returns:
      an Optional describing the minimum element of this stream, or an empty Optional if the stream is empty
    • max

      Optional<T> max(Comparator<? super T> comparator)
      Returns the maximum element of this stream according to the provided Comparator. This is a special case of a reduction.

      This is a terminal operation.

      Specified by:
      max in interface Stream<T>
      Parameters:
      comparator - a non-interfering, stateless Comparator to compare elements of this stream
      Returns:
      an Optional describing the maximum element of this stream, or an empty Optional if the stream is empty
    • max

      default Optional<T> max(Remote.Comparator<? super T> comparator)
      Returns the maximum element of this stream according to the provided Comparator. This is a special case of a reduction.

      This is a terminal operation.

      Parameters:
      comparator - a non-interfering, stateless Comparator to compare elements of this stream
      Returns:
      an Optional describing the maximum element of this stream, or an empty Optional if the stream is empty
    • max

      default <U> Optional<T> max(ValueExtractor<? super U,? extends Comparable> extractor)
      Returns the maximum element of this stream according to the attribute extracted by the provided ValueExtractor. This is a special case of a reduction.

      This is a terminal operation.

      Type Parameters:
      U - a super type of the value to extract from
      Parameters:
      extractor - a non-interfering, stateless ValueExtractor to be used to extract the attribute that should be used to compare stream elements
      Returns:
      an Optional describing the maximum element of this stream, or an empty Optional if the stream is empty
    • count

      long count()
      Returns the count of elements in this stream. This is a special case of a reduction and is equivalent to:
      
           return mapToLong(e -> 1L).sum();
       

      This is a terminal operation.

      Specified by:
      count in interface Stream<T>
      Returns:
      the count of elements in this stream
    • anyMatch

      boolean anyMatch(Predicate<? super T> predicate)
      Returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Specified by:
      anyMatch in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if any elements of the stream match the provided predicate, otherwise false
    • anyMatch

      default boolean anyMatch(Remote.Predicate<? super T> predicate)
      Returns whether any elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if any elements of the stream match the provided predicate, otherwise false
    • allMatch

      boolean allMatch(Predicate<? super T> predicate)
      Returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Specified by:
      allMatch in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if either all elements of the stream match the provided predicate or the stream is empty, otherwise false
    • allMatch

      default boolean allMatch(Remote.Predicate<? super T> predicate)
      Returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if either all elements of the stream match the provided predicate or the stream is empty, otherwise false
    • noneMatch

      boolean noneMatch(Predicate<? super T> predicate)
      Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Specified by:
      noneMatch in interface Stream<T>
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if either no elements of the stream match the provided predicate or the stream is empty, otherwise false
    • noneMatch

      default boolean noneMatch(Remote.Predicate<? super T> predicate)
      Returns whether no elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result.

      This is a short-circuiting terminal operation.

      Parameters:
      predicate - a non-interfering, stateless predicate to apply to elements of this stream
      Returns:
      true if either no elements of the stream match the provided predicate or the stream is empty, otherwise false
    • findFirst

      Optional<T> findFirst()
      Returns an Optional describing the first element of this stream, or an empty Optional if the stream is empty. If the stream has no encounter order, then any element may be returned.

      This is a short-circuiting terminal operation.

      Specified by:
      findFirst in interface Stream<T>
      Returns:
      an Optional describing the first element of this stream, or an empty Optional if the stream is empty
      Throws:
      NullPointerException - if the element selected is null
    • findAny

      Optional<T> findAny()
      Returns an Optional describing some element of the stream, or an empty Optional if the stream is empty.

      This is a short-circuiting terminal operation.

      The behavior of this operation is explicitly nondeterministic; it is free to select any element in the stream. This is to allow for maximal performance in parallel operations; the cost is that multiple invocations on the same source may not return the same result. (If a stable result is desired, use findFirst() instead.)

      Specified by:
      findAny in interface Stream<T>
      Returns:
      an Optional describing some element of this stream, or an empty Optional if the stream is empty
      Throws:
      NullPointerException - if the element selected is null
      See Also:
    • toIntStream

      static <T extends Number> RemoteIntStream toIntStream(RemoteStream<T> stream)
      Convert stream of numbers into RemoteIntStream.
      Type Parameters:
      T - the type of input stream elements
      Parameters:
      stream - the stream of numbers
      Returns:
      a RemoteIntStream instance
    • toLongStream

      static <T extends Number> RemoteLongStream toLongStream(RemoteStream<T> stream)
      Convert stream of numbers into RemoteLongStream.
      Type Parameters:
      T - the type of input stream elements
      Parameters:
      stream - the stream of numbers
      Returns:
      a RemoteLongStream instance
    • toDoubleStream

      static <T extends Number> RemoteDoubleStream toDoubleStream(RemoteStream<T> stream)
      Convert stream of numbers into RemoteDoubleStream.
      Type Parameters:
      T - the type of input stream elements
      Parameters:
      stream - the stream of numbers
      Returns:
      a RemoteDoubleStream instance