Interface RemoteStream<T>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      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 count()
      Returns the count of elements in this stream.
      Stream<T> distinct()
      Returns a stream consisting of the distinct elements (according to Object.equals(Object)) of this stream.
      static <K,​V>
      RemoteStream<InvocableMap.Entry<K,​V>>
      entrySet​(InvocableMap<K,​V> map)
      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.
      RemoteStream<T> filter​(Predicate<? super T> predicate)
      Returns a stream consisting of the elements of this stream that match the given predicate.
      Optional<T> findAny()
      Returns an Optional describing some element of the stream, or an empty Optional if the stream is empty.
      Optional<T> findFirst()
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      Stream<T> 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 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.
      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.
      RemoteDoubleStream mapToDouble​(ToDoubleFunction<? super T> mapper)
      Returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.
      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.
      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.
      RemoteIntStream mapToInt​(ToIntFunction<? super T> mapper)
      Returns an IntStream consisting of the results of applying the given function to the elements of this stream.
      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.
      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.
      RemoteLongStream 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.
      Optional<T> 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.
      Optional<T> 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.
      RemoteStream<T> parallel()
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      RemoteStream<T> sequential()
      Returns an equivalent stream that is sequential.
      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.
      RemoteStream<T> sorted()
      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.
      RemoteStream<T> sorted​(Comparator<? super T> comparator)
      Returns a stream consisting of the elements of this stream, sorted according to the provided Comparator.
      Object[] toArray()
      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
      toDoubleStream​(RemoteStream<T> stream)
      Convert stream of numbers into RemoteDoubleStream.
      static <T extends Number>
      RemoteIntStream
      toIntStream​(RemoteStream<T> stream)
      Convert stream of numbers into RemoteIntStream.
      static <T extends Number>
      RemoteLongStream
      toLongStream​(RemoteStream<T> stream)
      Convert stream of numbers into RemoteLongStream.
      RemoteStream<T> unordered()
      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.
    • Method Detail

      • 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:
        flatMap(Function)
      • 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:
        flatMap(Function)
      • 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:
        flatMap(Function)
      • 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:
        flatMap(Function)
      • 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:
        flatMap(Function)
      • 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:
        flatMap(Function)
      • 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
      • 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:
        forEach(Consumer)
      • 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(Object, Remote.BinaryOperator), min(Comparator), max(Comparator)
      • 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(Object, Remote.BinaryOperator), min(Comparator), max(Comparator)
      • 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(Remote.BinaryOperator), reduce(Object, Remote.BinaryOperator)
      • 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:
        reduce(Remote.BinaryOperator), reduce(Object, Remote.BinaryOperator)
      • 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(Remote.Supplier, Remote.BiConsumer, Remote.BiConsumer)
      • 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:
        collect(Remote.Supplier, Remote.BiConsumer, Remote.BiConsumer)
      • 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:
        findFirst()
      • toIntStream

        static <T extends NumberRemoteIntStream 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 NumberRemoteLongStream 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 NumberRemoteDoubleStream 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