Package com.landawn.abacus.util.stream
Class Stream<T>
java.lang.Object
com.landawn.abacus.util.stream.Stream<T>
- Type Parameters:
T
- the type of the stream elements
- All Implemented Interfaces:
Immutable
,BaseStream<T,
,Object[], Predicate<? super T>, Consumer<? super T>, List<T>, u.Optional<T>, Indexed<T>, ObjIterator<T>, Stream<T>> Closeable
,AutoCloseable
- Direct Known Subclasses:
Stream.StreamEx
Note: This class includes codes copied from StreamEx: https://github.com/amaembo/streamex under Apache License, version 2.0.
The Stream will be automatically closed after execution(A terminal method is executed/triggered).
The Stream will be automatically closed after execution(A terminal method is executed/triggered).
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.landawn.abacus.util.stream.BaseStream
BaseStream.ParallelSettings, BaseStream.Splitor
-
Method Summary
Modifier and TypeMethodDescription<SS extends BaseStream>
SSabstract <E extends Exception>
booleanallMatch
(Throwables.Predicate<? super T, E> predicate) abstract <E extends Exception>
booleananyMatch
(Throwables.Predicate<? super T, E> predicate) append
(Collection<? extends T> c) appendIfEmpty
(Collection<? extends T> c) appendIfEmpty
(T... a) <R> ContinuableFuture<R>
asyncCall
(Throwables.Function<? super Stream<T>, R, ? extends Exception> terminalAction) <R> ContinuableFuture<R>
asyncCall
(Throwables.Function<? super Stream<T>, R, ? extends Exception> terminalAction, Executor executor) asyncRun
(Throwables.Consumer<? super Stream<T>, ? extends Exception> terminalAction) asyncRun
(Throwables.Consumer<? super Stream<T>, ? extends Exception> terminalAction, Executor executor) abstract u.OptionalDouble
averageDouble
(ToDoubleFunction<? super T> mapper) abstract u.OptionalDouble
averageInt
(ToIntFunction<? super T> mapper) abstract u.OptionalDouble
averageLong
(ToLongFunction<? super T> mapper) buffered()
Returns a new Stream with elements from a temporary queue which is filled by reading the elements from this Stream asynchronously with a new thread.buffered
(int bufferSize) Returns a new Stream with elements from a temporary queue which is filled by reading the elements from this Stream asynchronously with a new thread.cartesianProduct
(Collection<? extends Collection<? extends T>> cs) cartesianProduct
(Collection<? extends T>... cs) <E extends Exception>
ExceptionalStream<T,E> checked()
<E extends Exception>
ExceptionalStream<T,E> void
close()
It will be called by terminal operations in final.collapse
(TriPredicate<? super T, ? super T, ? super T> collapsible) collapse
(TriPredicate<? super T, ? super T, ? super T> collapsible, BiFunction<? super T, ? super T, T> mergeFunction) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.abstract <C extends Collection<T>>
Stream<C>abstract <R> Stream<R>
collapse
(TriPredicate<? super T, ? super T, ? super T> collapsible, Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) abstract <R,
A> Stream<R> collapse
(TriPredicate<? super T, ? super T, ? super T> collapsible, Collector<? super T, A, R> collector) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.abstract <U> Stream<U>
collapse
(TriPredicate<? super T, ? super T, ? super T> collapsible, U init, BiFunction<U, ? super T, U> op) collapse
(BiPredicate<? super T, ? super T> collapsible) collapse
(BiPredicate<? super T, ? super T> collapsible, BiFunction<? super T, ? super T, T> mergeFunction) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.abstract <C extends Collection<T>>
Stream<C>collapse
(BiPredicate<? super T, ? super T> collapsible, Supplier<? extends C> supplier) abstract <R> Stream<R>
collapse
(BiPredicate<? super T, ? super T> collapsible, Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) abstract <R,
A> Stream<R> Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.abstract <U> Stream<U>
collapse
(BiPredicate<? super T, ? super T> collapsible, U init, BiFunction<U, ? super T, U> op) abstract <R> R
collect
(Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) abstract <R> R
collect
(Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator, BiConsumer<R, R> combiner) abstract <R,
A> R abstract <R,
A, RR, E extends Exception>
RRcollectAndThen
(Collector<? super T, A, R> downstream, Throwables.Function<? super R, RR, E> func) Stream.of(1, 2, 3).combinations().forEach(Fn.println()); // output [] [1] [2] [3] [1, 2] [1, 3] [2, 3] [1, 2, 3]
combinations
(int len) Stream.of(1, 2, 3).combinations(2).forEach(Fn.println()); // output [1, 2] [1, 3] [2, 3]
combinations
(int len, boolean repeat) It's same asN.cartesianProduct(N.repeat(toList(), len))
ifrepeat
istrue
.static <T> Stream<T>
static <T> Stream<T>
static <T> Stream<T>
concat
(Collection<? extends Stream<? extends T>> c) static <T> Stream<T>
static <T> Stream<T>
concat
(T[]... a) static <T> Stream<T>
concatIterables
(Collection<? extends Iterable<? extends T>> c) static <T> Stream<T>
concatIterators
(Collection<? extends Iterator<? extends T>> c) abstract boolean
containsAll
(Collection<? extends T> c) abstract boolean
containsAll
(T... a) abstract boolean
containsAny
(Collection<? extends T> c) abstract boolean
containsAny
(T... a) <K> EntryStream<K,
Integer> countByToEntry
(Function<? super T, ? extends K> keyMapper) defaultIfEmpty
(Supplier<? extends Stream<T>> supplier) defaultIfEmpty
(T defaultValue) static <T> Stream<T>
Lazy evaluation.difference
(Function<? super T, ? extends U> mapper, Collection<U> c) Except with the specified Collection by the values mapped bymapper
.distinct
(BinaryOperator<T> mergeFunction) Distinct and merge duplicated elements.Distinct and filter by occurrences.distinctBy
(Function<? super T, ?> keyMapper) Distinct by the value mapped fromkeyMapper
distinctBy
(Function<? super T, K> keyMapper, BinaryOperator<T> mergeFunction) Distinct and merge duplicated elements.distinctBy
(Function<? super T, K> keyMapper, Predicate<? super Long> occurrencesFilter) Distinct and filter by occurrences.elementAt
(long position) static <T> Stream<T>
empty()
filterE
(Throwables.Predicate<? super T, ? extends Exception> predicate) abstract <E extends Exception>
u.Optional<T>findAny
(Throwables.Predicate<? super T, E> predicate) Returns any element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned.abstract <E extends Exception>
u.Optional<T>findFirst
(Throwables.Predicate<? super T, E> predicate) Returns the first element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned.abstract <E extends Exception>
u.Optional<T>findFirstOrAny
(Throwables.Predicate<? super T, E> predicateForFirst) Returns the first element matched bypredicateForFirst
if found or the first element if this stream is not empty Otherwise an emptyOptional<T>
will be returned.abstract <E extends Exception,
E2 extends Exception>
u.Optional<T>findFirstOrAny
(Throwables.Predicate<? super T, E> predicateForFirst, Throwables.Predicate<? super T, E2> predicateForAny) Returns the first element matched bypredicateForFirst
if found or any element matched bypredicateForAny
(If this is a sequential stream, it will always be the first element matched bypredicateForAny
).abstract <E extends Exception>
u.Optional<T>findFirstOrLast
(Throwables.Predicate<? super T, E> predicateForFirst) Returns the first element matched bypredicateForFirst
if found or the last element if this stream is not empty Otherwise an emptyOptional<T>
will be returned.abstract <E extends Exception,
E2 extends Exception>
u.Optional<T>findFirstOrLast
(Throwables.Predicate<? super T, E> predicateForFirst, Throwables.Predicate<? super T, E2> predicateForLast) abstract <U,
E extends Exception, E2 extends Exception>
u.Optional<T>findFirstOrLast
(Function<? super T, U> preFunc, Throwables.BiPredicate<? super T, ? super U, E> predicateForFirst, Throwables.BiPredicate<? super T, ? super U, E2> predicateForLast)
This method only runs sequentially, even in parallel stream.abstract <U,
E extends Exception, E2 extends Exception>
u.Optional<T>findFirstOrLast
(U init, Throwables.BiPredicate<? super T, ? super U, E> predicateForFirst, Throwables.BiPredicate<? super T, ? super U, E2> predicateForLast)
This method only runs sequentially, even in parallel stream.abstract <E extends Exception>
u.Optional<T>findLast
(Throwables.Predicate<? super T, E> predicate) Returns the last element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned.flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Supplier<? extends M> mapFactory) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Collector<? super T, A, D> downstream) flatGroupTo
(Throwables.Function<? super T, ? extends Collection<? extends K>, E> flatKeyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) abstract <R> Stream<R>
<R> Stream<R>
flatMapE
(Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) abstract <R> Stream<R>
abstract <K,
V> EntryStream<K, V> flatMappToEntry
(Function<? super T, ? extends EntryStream<? extends K, ? extends V>> mapper) abstract ByteStream
flatMapToByte
(Function<? super T, ? extends ByteStream> mapper) abstract CharStream
flatMapToChar
(Function<? super T, ? extends CharStream> mapper) abstract DoubleStream
flatMapToDouble
(Function<? super T, ? extends DoubleStream> mapper) abstract <K,
V> EntryStream<K, V> flatMapToEntry
(Function<? super T, ? extends Stream<? extends Map.Entry<? extends K, ? extends V>>> mapper) abstract FloatStream
flatMapToFloat
(Function<? super T, ? extends FloatStream> mapper) abstract IntStream
flatMapToInt
(Function<? super T, ? extends IntStream> mapper) abstract LongStream
flatMapToLong
(Function<? super T, ? extends LongStream> mapper) abstract ShortStream
flatMapToShort
(Function<? super T, ? extends ShortStream> mapper) static <T> Stream<T>
flatten
(Collection<? extends Collection<? extends T>> c) static <T> Stream<T>
flatten
(T[][] a) static <T> Stream<T>
flatten
(T[][][] a) static <T> Stream<T>
flatten
(T[][] a, boolean vertically) static <T> Stream<T>
flatten
(T[][] a, T valueForNone, boolean vertically) abstract <R> Stream<R>
flattMap
(Function<? super T, ? extends Collection<? extends R>> mapper) <R> Stream<R>
flattMapE
(Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) <R> Stream<R>
flattMapIfNotNull
(Function<? super T, ? extends Collection<? extends R>> mapper) <U,
R> Stream<R> flattMapIfNotNull
(Function<? super T, ? extends Collection<? extends U>> mapper, Function<? super U, ? extends Collection<? extends R>> mapper2) abstract ByteStream
flattMapToByte
(Function<? super T, byte[]> mapper) abstract CharStream
flattMapToChar
(Function<? super T, char[]> mapper) abstract DoubleStream
flattMapToDouble
(Function<? super T, double[]> mapper) abstract <K,
V> EntryStream<K, V> flattMapToEntry
(Function<? super T, ? extends Map<? extends K, ? extends V>> mapper) abstract FloatStream
flattMapToFloat
(Function<? super T, float[]> mapper) abstract IntStream
flattMapToInt
(Function<? super T, int[]> mapper) abstract LongStream
flattMapToLong
(Function<? super T, long[]> mapper) abstract ShortStream
flattMapToShort
(Function<? super T, short[]> mapper) abstract <E extends Exception>
u.Optional<T>foldLeft
(Throwables.BinaryOperator<T, E> accumulator) This method will always run sequentially, even in parallel stream.abstract <U,
E extends Exception>
UfoldLeft
(U identity, Throwables.BiFunction<U, ? super T, U, E> accumulator) This method will always run sequentially, even in parallel stream.abstract <E extends Exception>
u.Optional<T>foldRight
(Throwables.BinaryOperator<T, E> accumulator) This method will always run sequentially, even in parallel stream.abstract <U,
E extends Exception>
UfoldRight
(U identity, Throwables.BiFunction<U, ? super T, U, E> accumulator) This method will always run sequentially, even in parallel stream.abstract <E extends Exception>
voidforEach
(Throwables.Consumer<? super T, E> action) forEach
(Throwables.Consumer<? super T, E> action, Throwables.Runnable<E2> onComplete) forEach
(Throwables.Function<? super T, ? extends Collection<? extends U>, E> flatMapper, Throwables.BiConsumer<? super T, ? super U, E2> action) forEach
(Throwables.Function<? super T, ? extends Collection<T2>, E> flatMapper, Throwables.Function<? super T2, ? extends Collection<T3>, E2> flatMapper2, Throwables.TriConsumer<? super T, ? super T2, ? super T3, E3> action) abstract <E extends Exception>
voidforEachIndexed
(Throwables.IndexedConsumer<? super T, E> action) abstract <E extends Exception>
voidforEachPair
(Throwables.BiConsumer<? super T, ? super T, E> action) abstract <E extends Exception>
voidforEachPair
(Throwables.BiConsumer<? super T, ? super T, E> action, int increment) Slide withwindowSize = 2
and the specifiedincrement
, thenconsume
by the specifiedmapper
.abstract <E extends Exception>
voidforEachTriple
(Throwables.TriConsumer<? super T, ? super T, ? super T, E> action) abstract <E extends Exception>
voidforEachTriple
(Throwables.TriConsumer<? super T, ? super T, ? super T, E> action, int increment) Slide withwindowSize = 3
and the specifiedincrement
, thenconsume
by the specifiedmapper
.abstract <E extends Exception>
voidforEachUntil
(MutableBoolean flagToBreak, Throwables.Consumer<? super T, E> action) abstract <E extends Exception>
voidforEachUntil
(Throwables.BiConsumer<? super T, MutableBoolean, E> action) static <T> Stream<T>
from
(Supplier<? extends Collection<T>> supplier) Lazy evaluation.static <T> Stream<T>
groupBy
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) groupBy
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends Map<K, V>> mapFactory) groupBy
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Supplier<? extends Map<K, List<V>>> mapFactory) groupBy
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream) groupBy
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) groupBy
(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) abstract <K> EntryStream<K,
List<T>> groupByToEntry
(Function<? super T, ? extends K> keyMapper) abstract <K,
V> EntryStream<K, List<V>> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) abstract <K,
V> EntryStream<K, V> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) abstract <K,
V> EntryStream<K, V> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends Map<K, V>> mapFactory) abstract <K,
V> EntryStream<K, List<V>> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Supplier<? extends Map<K, List<V>>> mapFactory) abstract <K,
V, A, D> EntryStream<K, D> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream) abstract <K,
V, A, D> EntryStream<K, D> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) abstract <K> EntryStream<K,
List<T>> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Supplier<? extends Map<K, List<T>>> mapFactory) abstract <K,
A, D> EntryStream<K, D> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream) abstract <K,
A, D> EntryStream<K, D> groupByToEntry
(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Supplier<? extends M> mapFactory) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Collector<? super T, A, D> downstream) groupTo
(Throwables.Function<? super T, ? extends K, E> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) abstract boolean
intersection
(Function<? super T, ? extends U> mapper, Collection<U> c) Intersect with the specified Collection by the values mapped bymapper
.intersperse
(T delimiter) Stream.of(1).intersperse(9) --> [1]
Stream.of(1, 2, 3).intersperse(9) --> [1, 9, 2, 9, 3]
This method only runs sequentially, even in parallel stream.static <T> Stream<T>
interval
(long delay, long interval, TimeUnit unit, LongFunction<T> s) static <T> Stream<T>
static <T> Stream<T>
interval
(long delayInMillis, long intervalInMillis, LongFunction<T> s) static <T> Stream<T>
static <T> Stream<T>
interval
(long intervalInMillis, LongFunction<T> s) static <T> Stream<T>
boolean
static <T> Stream<T>
iterate
(BooleanSupplier hasNext, Supplier<? extends T> next) static <T> Stream<T>
iterate
(T init, BooleanSupplier hasNext, UnaryOperator<T> f) Returns a sequential orderedStream
produced by iterative application of a functionf
to an initial elementinit
, producing aStream
consisting ofinit
,f(init)
,f(f(init))
, etc.static <T> Stream<T>
iterate
(T init, Predicate<? super T> hasNext, UnaryOperator<T> f) static <T> Stream<T>
iterate
(T init, UnaryOperator<T> f) iterator()
Remember to close this Stream after the iteration is done, if needed.abstract String
join
(CharSequence delimiter) static <T> Stream<T>
just
(T e) abstract u.Optional<T>
kthLargest
(int k, Comparator<? super T> comparator) last
(int n) A queue with size up ton
will be maintained to filter out the lastn
elements.It's user's responsibility to close the inputreader
after the stream is finished.abstract <R> Stream<R>
<R> Stream<R>
mapE
(Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) abstract <R> Stream<R>
mapFirstOrElse
(Function<? super T, ? extends R> mapperForFirst, Function<? super T, ? extends R> mapperForElse) abstract <R> Stream<R>
mapLastOrElse
(Function<? super T, ? extends R> mapperForLast, Function<? super T, ? extends R> mapperForElse) abstract <R> Stream<R>
mapMulti
(BiConsumer<? super T, ? super Consumer<R>> mapper) abstract DoubleStream
mapMultiToDouble
(BiConsumer<? super T, ? super DoubleConsumer> mapper) abstract IntStream
mapMultiToInt
(BiConsumer<? super T, ? super IntConsumer> mapper) abstract LongStream
mapMultiToLong
(BiConsumer<? super T, ? super LongConsumer> mapper) abstract <R> Stream<R>
mapPartial
(Function<? super T, u.Optional<? extends R>> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract <R> Stream<R>
mapPartialJdk
(Function<? super T, Optional<? extends R>> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract DoubleStream
mapPartialToDouble
(Function<? super T, u.OptionalDouble> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract DoubleStream
mapPartialToDoubleJdk
(Function<? super T, OptionalDouble> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract IntStream
mapPartialToInt
(Function<? super T, u.OptionalInt> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract IntStream
mapPartialToIntJdk
(Function<? super T, OptionalInt> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract LongStream
mapPartialToLong
(Function<? super T, u.OptionalLong> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract LongStream
mapPartialToLongJdk
(Function<? super T, OptionalLong> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamexabstract ByteStream
mapToByte
(ToByteFunction<? super T> mapper) abstract CharStream
mapToChar
(ToCharFunction<? super T> mapper) <K,
V> Stream<NoCachingNoUpdating.DisposableEntry<K, V>> mapToDisposableEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) Deprecated.abstract DoubleStream
mapToDouble
(ToDoubleFunction<? super T> mapper) abstract <K,
V> EntryStream<K, V> mapToEntry
(Function<? super T, ? extends Map.Entry<? extends K, ? extends V>> mapper) abstract <K,
V> EntryStream<K, V> mapToEntry
(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) abstract FloatStream
mapToFloat
(ToFloatFunction<? super T> mapper) abstract IntStream
mapToInt
(ToIntFunction<? super T> mapper) abstract LongStream
mapToLong
(ToLongFunction<? super T> mapper) abstract ShortStream
mapToShort
(ToShortFunction<? super T> mapper) abstract u.Optional<T>
max
(Comparator<? super T> comparator) maxAll
(Comparator<? super T> comparator) maxBy
(Function<? super T, ? extends Comparable> keyMapper) static <T> Stream<T>
merge
(Stream<? extends T> a, Stream<? extends T> b, Stream<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(Stream<? extends T> a, Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) merge
(Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) Deprecated.static <T> Stream<T>
merge
(Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(Iterable<? extends T> a, Iterable<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(Iterator<? extends T> a, Iterator<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(Iterator<? extends T> a, Iterator<? extends T> b, Iterator<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(T[] a, T[] b, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
merge
(T[] a, T[] b, T[] c, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
mergeIterables
(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector) static <T> Stream<T>
mergeIterators
(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector) mergeWith
(Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) mergeWith
(Collection<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) abstract u.Optional<T>
min
(Comparator<? super T> comparator) minAll
(Comparator<? super T> comparator) minBy
(Function<? super T, ? extends Comparable> keyMapper) abstract <E extends Exception>
booleannMatch
(long atLeast, long atMost, Throwables.Predicate<? super T, E> predicate) abstract <E extends Exception>
booleannoneMatch
(Throwables.Predicate<? super T, E> predicate) static <T> Stream<T>
observe
(BlockingQueue<T> queue, Duration duration) Sample code:static <T> Stream<T>
observe
(BlockingQueue<T> queue, BooleanSupplier hasMore, long maxWaitIntervalInMillis) Sample code:of
(boolean[] a) of
(boolean[] a, int fromIndex, int toIndex) of
(byte[] a) of
(byte[] a, int fromIndex, int toIndex) of
(char[] a) of
(char[] a, int fromIndex, int toIndex) of
(double[] a) of
(double[] a, int fromIndex, int toIndex) of
(float[] a) of
(float[] a, int fromIndex, int toIndex) of
(int[] a) of
(int[] a, int fromIndex, int toIndex) of
(long[] a) of
(long[] a, int fromIndex, int toIndex) of
(short[] a) of
(short[] a, int fromIndex, int toIndex) static <T> Stream<T>
of
(u.Optional<T> op) static <T> Stream<T>
static <T> Stream<T>
of
(Collection<? extends T> c) static <T> Stream<T>
of
(Collection<? extends T> c, int startIndex, int endIndex) static <T> Stream<T>
of
(Enumeration<? extends T> enumeration) static <T> Stream<T>
static <T> Stream<T>
static <T> Stream<T>
static <T> Stream<T>
of
(T... a) static <T> Stream<T>
of
(T[] a, int startIndex, int endIndex) static <K> Stream<K>
static <K,
V> Stream<K> ofKeys
(Map<? extends K, ? extends V> map, BiPredicate<? super K, ? super V> filter) static <K,
V> Stream<K> static <T> Stream<T>
ofNullable
(T e) Returns an emptyStream
if the specifiedt
is null.static <V> Stream<V>
static <K,
V> Stream<V> ofValues
(Map<? extends K, ? extends V> map, BiPredicate<? super K, ? super V> filter) static <K,
V> Stream<V> onEachE
(Throwables.Consumer<? super T, ? extends Exception> action) onErrorContinue
(Class<? extends Throwable> type, Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorContinue
(Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorContinue
(Predicate<? super Throwable> errorPredicate, Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorContinue
(Predicate<? super Throwable> errorPredicate, Consumer<? super Throwable> errorConsumer, int maxErrorCountToStop) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorReturn
(Class<? extends Throwable> type, T fallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorReturn
(Predicate<? super Throwable> predicate, Function<? super Throwable, ? extends T> mapperForFallbackValue, int maxErrorCountToStop) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorReturn
(Predicate<? super Throwable> predicate, Supplier<? extends T> supplierForFallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorReturn
(Predicate<? super Throwable> predicate, T fallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.onErrorReturn
(T fallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well.Stream.of(1, 2, 3).orderedPermutations().forEach(Fn.println()); // output [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1]
orderedPermutations
(Comparator<? super T> comparator) parallel()
Consider usingsps(Function)
if only next operation need to be parallelized.parallel
(int maxThreadNum) Consider usingsps(int, Function)
if only next operation need to be parallelized.parallel
(int maxThreadNum, BaseStream.Splitor splitor) Returns an equivalent stream that is parallel.parallel
(int maxThreadNum, BaseStream.Splitor splitor, Executor executor) Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized.Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized.Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized.parallel
(BaseStream.Splitor splitor) Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized.Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized.static <T> Stream<T>
parallelConcat
(Stream<? extends T>... a) static <T> Stream<T>
parallelConcat
(Stream<? extends T>[] a, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.static <T> Stream<T>
parallelConcat
(Iterable<? extends T>... a) static <T> Stream<T>
parallelConcat
(Iterable<? extends T>[] a, int readThreadNum, int bufferSize) static <T> Stream<T>
parallelConcat
(Collection<? extends Stream<? extends T>> c) static <T> Stream<T>
parallelConcat
(Collection<? extends Stream<? extends T>> c, int readThreadNum) static <T> Stream<T>
parallelConcat
(Collection<? extends Stream<? extends T>> c, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.static <T> Stream<T>
parallelConcat
(Iterator<? extends T>... a) static <T> Stream<T>
parallelConcat
(Iterator<? extends T>[] a, int readThreadNum, int bufferSize) static <T> Stream<T>
parallelConcatIterables
(Collection<? extends Iterable<? extends T>> c) static <T> Stream<T>
parallelConcatIterables
(Collection<? extends Iterable<? extends T>> c, int readThreadNum) static <T> Stream<T>
parallelConcatIterables
(Collection<? extends Iterable<? extends T>> c, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.static <T> Stream<T>
parallelConcatIterators
(Collection<? extends Iterator<? extends T>> c) static <T> Stream<T>
parallelConcatIterators
(Collection<? extends Iterator<? extends T>> c, int readThreadNum) static <T> Stream<T>
parallelConcatIterators
(Collection<? extends Iterator<? extends T>> c, int readThreadNum, int bufferSize) static <T> Stream<T>
parallelMerge
(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <T> Stream<T>
parallelMerge
(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <T> Stream<T>
parallelMergeIterables
(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <T> Stream<T>
parallelMergeIterables
(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <T> Stream<T>
parallelMergeIterators
(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <T> Stream<T>
parallelMergeIterators
(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads.static <A,
B, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, Stream<C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, Stream<C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, Stream<C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, Stream<C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Stream<A> a, Stream<B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZip
(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZip
(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZip
(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZip
(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <A,
B, C, R> Stream<R> parallelZip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterables
(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterables
(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterables
(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterables
(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterators
(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterators
(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterators
(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.static <T,
R> Stream<R> parallelZipIterators
(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
.partitionBy
(Predicate<? super T> predicate) partitionBy
(Predicate<? super T> predicate, Collector<? super T, A, D> downstream) abstract EntryStream<Boolean,
List<T>> partitionByToEntry
(Predicate<? super T> predicate) abstract <A,
D> EntryStream<Boolean, D> partitionByToEntry
(Predicate<? super T> predicate, Collector<? super T, A, D> downstream) partitionTo
(Throwables.Predicate<? super T, E> predicate) partitionTo
(Throwables.Predicate<? super T, E> predicate, Collector<? super T, A, D> downstream) abstract u.Optional<Map<Percentage,
T>> percentiles
(Comparator<? super T> comparator) Stream.of(1, 2, 3).permutations().forEach(Fn.println()); // output [1, 2, 3] [1, 3, 2] [3, 1, 2] [3, 2, 1] [2, 3, 1] [2, 1, 3]
abstract long
persist
(Throwables.BiConsumer<? super T, Writer, IOException> writeLine, File file) abstract long
persist
(Throwables.BiConsumer<? super T, Writer, IOException> writeLine, Writer writer) abstract long
persist
(Throwables.BiConsumer<? super T, Writer, IOException> writeLine, String header, String tail, File file) abstract long
persist
(Throwables.BiConsumer<? super T, Writer, IOException> writeLine, String header, String tail, Writer writer) abstract long
persist
(Throwables.Function<? super T, String, IOException> toLine, File file) toCSV:abstract long
persist
(Throwables.Function<? super T, String, IOException> toLine, OutputStream os) abstract long
persist
(Throwables.Function<? super T, String, IOException> toLine, Writer writer) toCSV:abstract long
persist
(Throwables.Function<? super T, String, IOException> toLine, String header, String tail, File file) abstract long
persist
(Throwables.Function<? super T, String, IOException> toLine, String header, String tail, Writer writer) abstract long
abstract long
abstract long
persist
(Connection conn, String insertSQL, int batchSize, int batchInterval, Throwables.BiConsumer<? super T, ? super PreparedStatement, SQLException> stmtSetter) abstract long
persist
(PreparedStatement stmt, int batchSize, int batchInterval, Throwables.BiConsumer<? super T, ? super PreparedStatement, SQLException> stmtSetter) abstract long
persistToCSV
(File file) Each line in the output file/Writer is an array of JSON String without root bracket.abstract long
Each line in the output file/Writer is an array of JSON String without root bracket.abstract long
persistToCSV
(Writer writer) Each line in the output file/Writer is an array of JSON String without root bracket.abstract long
persistToCSV
(Collection<String> csvHeaders, File file) Each line in the output file/Writer is an array of JSON String without root bracket.abstract long
persistToCSV
(Collection<String> csvHeaders, OutputStream os) Each line in the output file/Writer is an array of JSON String without root bracket.abstract long
persistToCSV
(Collection<String> csvHeaders, Writer writer) Each line in the output file/Writer is an array of JSON String without root bracket.prepend
(Collection<? extends T> c) void
println()
<SS extends BaseStream>
SSTemporarily switch the stream to sequence stream for operationops
and then switch back to parallel stream with samemaxThreadNum/splitor/asyncExecutor
.range
(int startInclusive, int endExclusive) range
(int startInclusive, int endExclusive, int by) range
(long startInclusive, long endExclusive) range
(long startInclusive, long endExclusive, long by) rangeClosed
(int startInclusive, int endInclusive) rangeClosed
(int startInclusive, int endInclusive, int by) rangeClosed
(long startInclusive, long endInclusive) rangeClosed
(long startInclusive, long endInclusive, long by) abstract <U> Stream<U>
rangeMap
(BiPredicate<? super T, ? super T> sameRange, BiFunction<? super T, ? super T, ? extends U> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex
Returns a stream consisting of results of applying the given function to the ranges created from the source elements.rateLimited
(double permitsPerSecond) rateLimited
(RateLimiter rateLimiter) abstract <E extends Exception>
u.Optional<T>reduce
(Throwables.BinaryOperator<T, E> accumulator) reduce
(T identity, Throwables.BinaryOperator<T, E> accumulator) abstract <U,
E extends Exception>
Ureduce
(U identity, Throwables.BiFunction<U, ? super T, U, E> accumulator, Throwables.BinaryOperator<U, E> combiner) abstract <E extends Exception>
u.Optional<T>reduceUntil
(Throwables.BinaryOperator<T, E> accumulator, Throwables.Predicate<? super T, E> conditionToBreak) reduceUntil
(T identity, Throwables.BinaryOperator<T, E> accumulator, Throwables.Predicate<? super T, E> conditionToBreak) abstract <U,
E extends Exception>
UreduceUntil
(U identity, Throwables.BiFunction<U, ? super T, U, E> accumulator, Throwables.BinaryOperator<U, E> combiner, Throwables.Predicate<? super U, E> conditionToBreak) static <T> Stream<T>
repeat
(T element, long n) reverseSorted
(Comparator<? super T> comparator) rollup()
scan
(BiFunction<? super T, ? super T, T> accumulator) Returns aStream
produced by iterative application of a accumulation function to an initial elementinit
and next element of the current stream.abstract <U> Stream<U>
scan
(U init, BiFunction<U, ? super T, U> accumulator) Returns aStream
produced by iterative application of a accumulation function to an initial elementinit
and next element of the current stream.abstract <U> Stream<U>
scan
(U init, BiFunction<U, ? super T, U> accumulator, boolean initIncluded) <U> Stream<U>
Select the elements belong to the specifiedtargetType
(including its subtype).shuffled()
This method only runs sequentially, even in parallel stream and all elements will be loaded to memory.skipLast
(int n) A queue with size up ton
will be maintained to filter out the lastn
elements.skipNull()
skipRange
(int startInclusive, int endExclusive) Skip the range: [fromIndexInclusive, fromIndexInclusive]sliding
(int windowSize) abstract <C extends Collection<T>>
Stream<C>sliding
(int windowSize, int increment, IntFunction<? extends C> collectionSupplier) abstract <A,
R> Stream<R> abstract <C extends Collection<T>>
Stream<C>sliding
(int windowSize, IntFunction<? extends C> collectionSupplier) abstract <A,
R> Stream<R> abstract <R> Stream<R>
slidingMap
(TriFunction<? super T, ? super T, ? super T, R> mapper) abstract <R> Stream<R>
slidingMap
(TriFunction<? super T, ? super T, ? super T, R> mapper, int increment) Slide withwindowSize = 3
and the specifiedincrement
, thenmap
by the specifiedmapper
.abstract <R> Stream<R>
slidingMap
(TriFunction<? super T, ? super T, ? super T, R> mapper, int increment, boolean ignoreNotPaired) abstract <R> Stream<R>
slidingMap
(BiFunction<? super T, ? super T, R> mapper) abstract <R> Stream<R>
slidingMap
(BiFunction<? super T, ? super T, R> mapper, int increment) Slide withwindowSize = 2
and the specifiedincrement
, thenmap
by the specifiedmapper
.abstract <R> Stream<R>
slidingMap
(BiFunction<? super T, ? super T, R> mapper, int increment, boolean ignoreNotPaired) slidingToList
(int windowSize) slidingToSet
(int windowSize) slidingToSet
(int windowSize, int increment) sorted
(Comparator<? super T> comparator) sortedBy
(Function<? super T, ? extends Comparable> keyMapper) sortedByDouble
(ToDoubleFunction<? super T> keyMapper) sortedByInt
(ToIntFunction<? super T> keyMapper) sortedByLong
(ToLongFunction<? super T> keyMapper) abstract <C extends Collection<T>>
Stream<C>split
(int chunkSize, IntFunction<? extends C> collectionSupplier) Returns Stream of Stream with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).abstract <A,
R> Stream<R> split
(CharSequence str, CharSequence delimiter) abstract <C extends Collection<T>>
Stream<C>abstract <A,
R> Stream<R> abstract <A,
R> Stream<R> Split the stream into two pieces atwhere
turns tofalse
.abstract <A,
R> Stream<R> Split the stream into two pieces atwhere
turns tofalse
.splitToSet
(int chunkSize) Returns Stream of Stream with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).splitToSet
(Predicate<? super T> predicate) <R> Stream<R>
Temporarily switch the stream to parallel stream for operationop
and then switch back to sequence stream.<SS extends BaseStream>
SSTemporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.<SS extends BaseStream>
SSsps
(BaseStream.ParallelSettings ps, Function<? super Stream<T>, ? extends SS> ops) Temporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.<SS extends BaseStream>
SSTemporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.spsFilterE
(int maxThreadNum, Throwables.Predicate<? super T, ? extends Exception> predicate) Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.spsFilterE
(Throwables.Predicate<? super T, ? extends Exception> predicate) Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.<R> Stream<R>
spsFlatMap
(int maxThreadNum, int bufferSize, Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlatMap
(int maxThreadNum, Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlatMap
(Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlatMapE
(int maxThreadNum, Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlatMapE
(Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlattMap
(int maxThreadNum, int bufferSize, Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlattMap
(int maxThreadNum, Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlattMap
(Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlattMapE
(int maxThreadNum, Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
spsFlattMapE
(Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.<R> Stream<R>
Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.<R> Stream<R>
Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.<R> Stream<R>
Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.<R> Stream<R>
spsMapE
(int maxThreadNum, Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.<R> Stream<R>
spsMapE
(Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.spsOnEachE
(int maxThreadNum, Throwables.Consumer<? super T, ? extends Exception> action) Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.spsOnEachE
(Throwables.Consumer<? super T, ? extends Exception> action) Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.abstract double
sumDouble
(ToDoubleFunction<? super T> mapper) abstract long
sumInt
(ToIntFunction<? super T> mapper) abstract long
sumLong
(ToLongFunction<? super T> mapper) throwIfEmpty
(Supplier<? extends RuntimeException> exceptionSupplier) Object[]
toArray()
abstract <A> A[]
toArray
(IntFunction<A[]> generator) abstract <R,
CC extends Collection<T>, E extends Exception>
RtoCollectionAndThen
(Supplier<? extends CC> supplier, Throwables.Function<? super CC, R, E> func) abstract DataSet
The first row will be used as column names if its type is array or list, or obtain the column names from first row if its type is entity or map.abstract DataSet
If the specifiedcolumnNames
is null or empty, the first row will be used as column names if its type is array or list, or obtain the column names from first row if its type is entity or map.<K,
V, E extends Exception, E2 extends Exception>
ImmutableMap<K,V> toImmutableMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) <K,
V, E extends Exception, E2 extends Exception>
ImmutableMap<K,V> toImmutableMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction) Remember to close this Stream after the iteration is done, if needed.abstract <R,
E extends Exception>
RtoListAndThen
(Throwables.Function<? super List<T>, R, E> func) toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction) toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends M> mapFactory) toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) Deprecated.replaced bygroupTo
toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) Deprecated.replaced bygroupTo
toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Collector<? super T, A, D> downstream) Deprecated.replaced bygroupTo
toMap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) Deprecated.replaced bygroupTo
abstract <K,
E extends Exception>
ListMultimap<K,T> toMultimap
(Throwables.Function<? super T, ? extends K, E> keyMapper) abstract <K,
V, E extends Exception, E2 extends Exception>
ListMultimap<K,V> toMultimap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) abstract <K,
V, C extends Collection<V>, M extends Multimap<K, V, C>, E extends Exception, E2 extends Exception>
MtoMultimap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) abstract <K,
V extends Collection<T>, M extends Multimap<K, T, V>, E extends Exception>
MtoMultimap
(Throwables.Function<? super T, ? extends K, E> keyMapper, Supplier<? extends M> mapFactory) top
(int n)
This method only runs sequentially, even in parallel stream.top
(int n, Comparator<? super T> comparator)
This method only runs sequentially, even in parallel stream.abstract <R,
E extends Exception>
RtoSetAndThen
(Throwables.Function<? super Set<T>, R, E> func) static <R> Stream<R>
zip
(byte[] a, byte[] b, byte[] c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(byte[] a, byte[] b, byte[] c, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(byte[] a, byte[] b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(byte[] a, byte[] b, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(char[] a, char[] b, char[] c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(char[] a, char[] b, char[] c, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(char[] a, char[] b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(char[] a, char[] b, CharBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(double[] a, double[] b, double[] c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(double[] a, double[] b, double[] c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(double[] a, double[] b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(double[] a, double[] b, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(float[] a, float[] b, float[] c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(float[] a, float[] b, float[] c, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(float[] a, float[] b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(float[] a, float[] b, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(int[] a, int[] b, int[] c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(int[] a, int[] b, int[] c, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(int[] a, int[] b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(int[] a, int[] b, IntBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(long[] a, long[] b, long[] c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(long[] a, long[] b, long[] c, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(long[] a, long[] b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(long[] a, long[] b, LongBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(short[] a, short[] b, short[] c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(short[] a, short[] b, short[] c, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <R> Stream<R>
zip
(short[] a, short[] b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(short[] a, short[] b, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <A,
B, R> Stream<R> zip
(A[] a, B[] b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(A[] a, B[] b, C[] c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(A[] a, B[] b, C[] c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <A,
B, R> Stream<R> zip
(A[] a, B[] b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(ByteIterator a, ByteIterator b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ByteIterator a, ByteIterator b, ByteIterator c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ByteIterator a, ByteIterator b, ByteIterator c, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(ByteIterator a, ByteIterator b, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(CharIterator a, CharIterator b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(CharIterator a, CharIterator b, CharIterator c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(CharIterator a, CharIterator b, CharIterator c, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(CharIterator a, CharIterator b, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(DoubleIterator a, DoubleIterator b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(DoubleIterator a, DoubleIterator b, DoubleIterator c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(DoubleIterator a, DoubleIterator b, DoubleIterator c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(DoubleIterator a, DoubleIterator b, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(FloatIterator a, FloatIterator b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(FloatIterator a, FloatIterator b, FloatIterator c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(FloatIterator a, FloatIterator b, FloatIterator c, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(FloatIterator a, FloatIterator b, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(IntIterator a, IntIterator b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(IntIterator a, IntIterator b, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(IntIterator a, IntIterator b, IntIterator c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(IntIterator a, IntIterator b, IntIterator c, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(LongIterator a, LongIterator b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(LongIterator a, LongIterator b, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(LongIterator a, LongIterator b, LongIterator c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(LongIterator a, LongIterator b, LongIterator c, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(ShortIterator a, ShortIterator b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ShortIterator a, ShortIterator b, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <R> Stream<R>
zip
(ShortIterator a, ShortIterator b, ShortIterator c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ShortIterator a, ShortIterator b, ShortIterator c, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <R> Stream<R>
zip
(ByteStream a, ByteStream b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ByteStream a, ByteStream b, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(ByteStream a, ByteStream b, ByteStream c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ByteStream a, ByteStream b, ByteStream c, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(CharStream a, CharStream b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(CharStream a, CharStream b, CharBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(CharStream a, CharStream b, CharStream c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(CharStream a, CharStream b, CharStream c, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(DoubleStream a, DoubleStream b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(DoubleStream a, DoubleStream b, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(DoubleStream a, DoubleStream b, DoubleStream c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(DoubleStream a, DoubleStream b, DoubleStream c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(FloatStream a, FloatStream b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(FloatStream a, FloatStream b, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(FloatStream a, FloatStream b, FloatStream c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(FloatStream a, FloatStream b, FloatStream c, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(IntStream a, IntStream b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(IntStream a, IntStream b, IntBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(IntStream a, IntStream b, IntStream c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(IntStream a, IntStream b, IntStream c, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(LongStream a, LongStream b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(LongStream a, LongStream b, LongBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(LongStream a, LongStream b, LongStream c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(LongStream a, LongStream b, LongStream c, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <R> Stream<R>
zip
(ShortStream a, ShortStream b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ShortStream a, ShortStream b, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <R> Stream<R>
zip
(ShortStream a, ShortStream b, ShortStream c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <R> Stream<R>
zip
(ShortStream a, ShortStream b, ShortStream c, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <A,
B, R> Stream<R> zip
(Stream<? extends A> a, Stream<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Stream<? extends A> a, Stream<? extends B> b, Stream<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Stream<? extends A> a, Stream<? extends B> b, Stream<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values.static <A,
B, R> Stream<R> zip
(Stream<? extends A> a, Stream<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values.static <A,
B, R> Stream<R> zip
(Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values.static <A,
B, R> Stream<R> zip
(Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends ByteStream> c, byte[] valuesForNone, ByteNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends ByteStream> c, ByteNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends CharStream> c, char[] valuesForNone, CharNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends CharStream> c, CharNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends DoubleStream> c, double[] valuesForNone, DoubleNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends DoubleStream> c, DoubleNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends FloatStream> c, float[] valuesForNone, FloatNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends FloatStream> c, FloatNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends IntStream> c, int[] valuesForNone, IntNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends IntStream> c, IntNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends LongStream> c, long[] valuesForNone, LongNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends LongStream> c, LongNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends ShortStream> c, short[] valuesForNone, ShortNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values.static <R> Stream<R>
zip
(Collection<? extends ShortStream> c, ShortNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values.static <T,
R> Stream<R> zip
(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction) Zip together the iterators until one of them runs out of values.static <T,
R> Stream<R> zip
(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) Zip together the iterators until all of them runs out of values.static <A,
B, R> Stream<R> zip
(Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values.static <A,
B, R> Stream<R> zip
(Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values.static <A,
B, C, R> Stream<R> zip
(Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values.static <T,
R> Stream<R> zipIterables
(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction) static <T,
R> Stream<R> zipIterables
(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) static <T,
R> Stream<R> zipIterators
(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction) static <T,
R> Stream<R> zipIterators
(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) abstract <T2,
T3, R> Stream<R> zipWith
(Stream<T2> b, Stream<T3> c, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) abstract <T2,
T3, R> Stream<R> zipWith
(Stream<T2> b, Stream<T3> c, T valueForNoneA, T2 valueForNoneB, T3 valueForNoneC, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) abstract <T2,
R> Stream<R> zipWith
(Stream<T2> b, BiFunction<? super T, ? super T2, R> zipFunction) abstract <T2,
R> Stream<R> zipWith
(Stream<T2> b, T valueForNoneA, T2 valueForNoneB, BiFunction<? super T, ? super T2, R> zipFunction) abstract <T2,
T3, R> Stream<R> zipWith
(Collection<T2> b, Collection<T3> c, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) abstract <T2,
T3, R> Stream<R> zipWith
(Collection<T2> b, Collection<T3> c, T valueForNoneA, T2 valueForNoneB, T3 valueForNoneC, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) abstract <T2,
R> Stream<R> zipWith
(Collection<T2> b, BiFunction<? super T, ? super T2, R> zipFunction) abstract <T2,
R> Stream<R> zipWith
(Collection<T2> b, T valueForNoneA, T2 valueForNoneB, BiFunction<? super T, ? super T2, R> zipFunction) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.landawn.abacus.util.stream.BaseStream
acceptIfNotEmpty, append, append, appendIfEmpty, applyIfNotEmpty, count, cycled, cycled, difference, distinct, dropWhile, dropWhile, filter, filter, first, indexed, intersection, join, last, limit, onClose, onEach, onlyOne, percentiles, prepend, prepend, removeIf, removeIf, reversed, reverseSorted, rotated, shuffled, skip, skip, sliding, slidingToList, sorted, split, split, splitAt, splitAt, splitToList, splitToList, step, symmetricDifference, takeWhile, toCollection, toList, toLongMultiset, toLongMultiset, toMultiset, toMultiset, toSet
-
Method Details
-
select
Select the elements belong to the specifiedtargetType
(including its subtype).- Type Parameters:
U
-- Parameters:
targetType
-- Returns:
-
skipUntil
- Parameters:
predicate
-- Returns:
- See Also:
-
map
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> map(Function<? super T, ? extends R> mapper) -
pairWith
@ParallelSupported @IntermediateOp public <U> Stream<Pair<T,U>> pairWith(Function<? super T, ? extends U> extractor) -
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(BiFunction<? super T, ? super T, R> mapper) -
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(BiFunction<? super T, ? super T, R> mapper, int increment) Slide withwindowSize = 2
and the specifiedincrement
, thenmap
by the specifiedmapper
.- Parameters:
mapper
-increment
-- Returns:
-
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(BiFunction<? super T, ? super T, R> mapper, int increment, boolean ignoreNotPaired) -
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(TriFunction<? super T, ? super T, ? super T, R> mapper) -
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(TriFunction<? super T, ? super T, ? super T, R> mapper, int increment) Slide withwindowSize = 3
and the specifiedincrement
, thenmap
by the specifiedmapper
.- Parameters:
mapper
-increment
-- Returns:
-
slidingMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> slidingMap(TriFunction<? super T, ? super T, ? super T, R> mapper, int increment, boolean ignoreNotPaired) -
rangeMap
@SequentialOnly @IntermediateOp public abstract <U> Stream<U> rangeMap(BiPredicate<? super T, ? super T> sameRange, BiFunction<? super T, ? super T, ? extends U> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex
Returns a stream consisting of results of applying the given function to the ranges created from the source elements.Stream.of("a", "ab", "ac", "b", "c", "cb").rangeMap((a, b) -> b.startsWith(a), (a, b) -> a + "->" + b).toList(); // a->ac, b->b, c->cb
This is a quasi-intermediate partial reduction operation.
- Type Parameters:
U
- the type of the resulting elements- Parameters:
sameRange
- a non-interfering, stateless predicate to apply to the leftmost and next elements which returns true for elements which belong to the same range.mapper
- a non-interfering, stateless function to apply to the range borders and produce the resulting element. If value was not merged to the interval, then mapper will receive the same value twice, otherwise it will receive the leftmost and the rightmost values which were merged to the range.- Returns:
- See Also:
-
#collapse(BiPredicate, BinaryOperator)
-
mapFirst
@SequentialOnly @IntermediateOp public abstract Stream<T> mapFirst(Function<? super T, ? extends T> mapperForFirst) -
mapFirstOrElse
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> mapFirstOrElse(Function<? super T, ? extends R> mapperForFirst, Function<? super T, ? extends R> mapperForElse) -
mapLast
@SequentialOnly @IntermediateOp public abstract Stream<T> mapLast(Function<? super T, ? extends T> mapperForLast) -
mapLastOrElse
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> mapLastOrElse(Function<? super T, ? extends R> mapperForLast, Function<? super T, ? extends R> mapperForElse) -
mapToChar
@ParallelSupported @IntermediateOp public abstract CharStream mapToChar(ToCharFunction<? super T> mapper) -
mapToByte
@ParallelSupported @IntermediateOp public abstract ByteStream mapToByte(ToByteFunction<? super T> mapper) -
mapToShort
@ParallelSupported @IntermediateOp public abstract ShortStream mapToShort(ToShortFunction<? super T> mapper) -
mapToInt
@ParallelSupported @IntermediateOp public abstract IntStream mapToInt(ToIntFunction<? super T> mapper) -
mapToLong
@ParallelSupported @IntermediateOp public abstract LongStream mapToLong(ToLongFunction<? super T> mapper) -
mapToFloat
@ParallelSupported @IntermediateOp public abstract FloatStream mapToFloat(ToFloatFunction<? super T> mapper) -
mapToDouble
@ParallelSupported @IntermediateOp public abstract DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) -
mapToEntry
@ParallelSupported @IntermediateOp public abstract <K,V> EntryStream<K,V> mapToEntry(Function<? super T, ? extends Map.Entry<? extends K, ? extends V>> mapper) -
mapToEntry
@ParallelSupported @IntermediateOp public abstract <K,V> EntryStream<K,V> mapToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) -
flatMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) -
flattMap
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> flattMap(Function<? super T, ? extends Collection<? extends R>> mapper) -
flatMapp
@ParallelSupported @IntermediateOp public abstract <R> Stream<R> flatMapp(Function<? super T, R[]> mapper) -
flatMapToChar
@ParallelSupported @IntermediateOp public abstract CharStream flatMapToChar(Function<? super T, ? extends CharStream> mapper) -
flattMapToChar
@ParallelSupported @IntermediateOp public abstract CharStream flattMapToChar(Function<? super T, char[]> mapper) -
flatMapToByte
@ParallelSupported @IntermediateOp public abstract ByteStream flatMapToByte(Function<? super T, ? extends ByteStream> mapper) -
flattMapToByte
@ParallelSupported @IntermediateOp public abstract ByteStream flattMapToByte(Function<? super T, byte[]> mapper) -
flatMapToShort
@ParallelSupported @IntermediateOp public abstract ShortStream flatMapToShort(Function<? super T, ? extends ShortStream> mapper) -
flattMapToShort
@ParallelSupported @IntermediateOp public abstract ShortStream flattMapToShort(Function<? super T, short[]> mapper) -
flatMapToInt
@ParallelSupported @IntermediateOp public abstract IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) -
flattMapToInt
@ParallelSupported @IntermediateOp public abstract IntStream flattMapToInt(Function<? super T, int[]> mapper) -
flatMapToLong
@ParallelSupported @IntermediateOp public abstract LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) -
flattMapToLong
@ParallelSupported @IntermediateOp public abstract LongStream flattMapToLong(Function<? super T, long[]> mapper) -
flatMapToFloat
@ParallelSupported @IntermediateOp public abstract FloatStream flatMapToFloat(Function<? super T, ? extends FloatStream> mapper) -
flattMapToFloat
@ParallelSupported @IntermediateOp public abstract FloatStream flattMapToFloat(Function<? super T, float[]> mapper) -
flatMapToDouble
@ParallelSupported @IntermediateOp public abstract DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) -
flattMapToDouble
@ParallelSupported @IntermediateOp public abstract DoubleStream flattMapToDouble(Function<? super T, double[]> mapper) -
flatMapToEntry
@ParallelSupported @IntermediateOp public abstract <K,V> EntryStream<K,V> flatMapToEntry(Function<? super T, ? extends Stream<? extends Map.Entry<? extends K, ? extends V>>> mapper) -
flattMapToEntry
@ParallelSupported @IntermediateOp public abstract <K,V> EntryStream<K,V> flattMapToEntry(Function<? super T, ? extends Map<? extends K, ? extends V>> mapper) -
flatMappToEntry
@ParallelSupported @IntermediateOp public abstract <K,V> EntryStream<K,V> flatMappToEntry(Function<? super T, ? extends EntryStream<? extends K, ? extends V>> mapper) -
flattMapIfNotNull
@Beta @ParallelSupported @IntermediateOp public <R> Stream<R> flattMapIfNotNull(Function<? super T, ? extends Collection<? extends R>> mapper) - Type Parameters:
R
-- Parameters:
mapper
-- Returns:
-
flattMapIfNotNull
@Beta @ParallelSupported @IntermediateOp public <U,R> Stream<R> flattMapIfNotNull(Function<? super T, ? extends Collection<? extends U>> mapper, Function<? super U, ? extends Collection<? extends R>> mapper2) - Type Parameters:
U
-R
-- Parameters:
mapper
-mapper2
-- Returns:
-
mapMulti
@Beta @ParallelSupported @IntermediateOp public abstract <R> Stream<R> mapMulti(BiConsumer<? super T, ? super Consumer<R>> mapper) -
mapMultiToInt
@Beta @ParallelSupported @IntermediateOp public abstract IntStream mapMultiToInt(BiConsumer<? super T, ? super IntConsumer> mapper) -
mapMultiToLong
@Beta @ParallelSupported @IntermediateOp public abstract LongStream mapMultiToLong(BiConsumer<? super T, ? super LongConsumer> mapper) -
mapMultiToDouble
@Beta @ParallelSupported @IntermediateOp public abstract DoubleStream mapMultiToDouble(BiConsumer<? super T, ? super DoubleConsumer> mapper) -
mapPartial
@Beta @ParallelSupported @IntermediateOp public abstract <R> Stream<R> mapPartial(Function<? super T, u.Optional<? extends R>> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
-
mapPartialToInt
@Beta @ParallelSupported @IntermediateOp public abstract IntStream mapPartialToInt(Function<? super T, u.OptionalInt> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
mapPartialToLong
@Beta @ParallelSupported @IntermediateOp public abstract LongStream mapPartialToLong(Function<? super T, u.OptionalLong> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
mapPartialToDouble
@Beta @ParallelSupported @IntermediateOp public abstract DoubleStream mapPartialToDouble(Function<? super T, u.OptionalDouble> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
mapPartialJdk
@Beta @ParallelSupported @IntermediateOp public abstract <R> Stream<R> mapPartialJdk(Function<? super T, Optional<? extends R>> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
-
mapPartialToIntJdk
@Beta @ParallelSupported @IntermediateOp public abstract IntStream mapPartialToIntJdk(Function<? super T, OptionalInt> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
mapPartialToLongJdk
@Beta @ParallelSupported @IntermediateOp public abstract LongStream mapPartialToLongJdk(Function<? super T, OptionalLong> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
mapPartialToDoubleJdk
@Beta @ParallelSupported @IntermediateOp public abstract DoubleStream mapPartialToDoubleJdk(Function<? super T, OptionalDouble> mapper) Note: copied from StreamEx: https://github.com/amaembo/streamex- Parameters:
mapper
-- Returns:
-
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K> Stream<Map.Entry<K,List<T>>> groupBy(Function<? super T, ? extends K> keyMapper) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K> Stream<Map.Entry<K,List<T>>> groupBy(Function<? super T, ? extends K> keyMapper, Supplier<? extends Map<K, List<T>>> mapFactory) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> Stream<Map.Entry<K,List<V>>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) - Parameters:
keyMapper
-valueMapper
-- Returns:
- See Also:
-
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> Stream<Map.Entry<K,List<V>>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Supplier<? extends Map<K, List<V>>> mapFactory) - Parameters:
keyMapper
-valueMapper
-mapFactory
-- Returns:
- See Also:
-
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,A, Stream<Map.Entry<K,D> D>> groupBy(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,A, Stream<Map.Entry<K,D> D>> groupBy(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V, Stream<Map.Entry<K,A, D> D>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V, Stream<Map.Entry<K,A, D> D>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) - Type Parameters:
K
-V
-A
- // TODO do we need AD
-- Parameters:
keyMapper
-valueMapper
-downstream
-mapFactory
-- Returns:
-
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> Stream<Map.Entry<K,V>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) -
groupBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> Stream<Map.Entry<K,V>> groupBy(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends Map<K, V>> mapFactory) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K> EntryStream<K,List<T>> groupByToEntry(Function<? super T, ? extends K> keyMapper) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K> EntryStream<K,List<T>> groupByToEntry(Function<? super T, ? extends K> keyMapper, Supplier<? extends Map<K, List<T>>> mapFactory) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> EntryStream<K,List<V>> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) - Parameters:
keyMapper
-valueMapper
-- Returns:
- See Also:
-
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> EntryStream<K,List<V>> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Supplier<? extends Map<K, List<V>>> mapFactory) - Parameters:
keyMapper
-valueMapper
-mapFactory
-- Returns:
- See Also:
-
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,A, EntryStream<K,D> D> groupByToEntry(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,A, EntryStream<K,D> D> groupByToEntry(Function<? super T, ? extends K> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V, EntryStream<K,A, D> D> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V, EntryStream<K,A, D> D> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends Map<K, D>> mapFactory) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> EntryStream<K,V> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction) -
groupByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <K,V> EntryStream<K,V> groupByToEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends Map<K, V>> mapFactory) -
partitionBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<Map.Entry<Boolean,List<T>>> partitionBy(Predicate<? super T> predicate) - Parameters:
predicate
-- Returns:
- See Also:
-
partitionBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <A,D> Stream<Map.Entry<Boolean,D>> partitionBy(Predicate<? super T> predicate, Collector<? super T, A, D> downstream) - Parameters:
predicate
-downstream
-- Returns:
- See Also:
-
partitionByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract EntryStream<Boolean,List<T>> partitionByToEntry(Predicate<? super T> predicate) - Parameters:
predicate
-- Returns:
- See Also:
-
partitionByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract <A,D> EntryStream<Boolean,D> partitionByToEntry(Predicate<? super T> predicate, Collector<? super T, A, D> downstream) - Parameters:
predicate
-downstream
-- Returns:
- See Also:
-
countBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public <K> Stream<Map.Entry<K,Integer>> countBy(Function<? super T, ? extends K> keyMapper) -
countByToEntry
@ParallelSupported @IntermediateOp @TerminalOpTriggered public <K> EntryStream<K,Integer> countByToEntry(Function<? super T, ? extends K> keyMapper) -
collapse
@SequentialOnly @IntermediateOp public abstract Stream<Stream<T>> collapse(BiPredicate<? super T, ? super T> collapsible) - Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.- Returns:
-
collapse
@SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> collapse(BiPredicate<? super T, ? super T> collapsible, Supplier<? extends C> supplier) - Type Parameters:
C
-- Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.supplier
-- Returns:
-
collapse
@SequentialOnly @IntermediateOp public abstract Stream<T> collapse(BiPredicate<? super T, ? super T> collapsible, BiFunction<? super T, ? super T, T> mergeFunction) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.Example:
Stream.of(new Integer[0]).collapse((p, c) -> p < c, (r, c) -> r + c) => [] Stream.of(1).collapse((p, c) -> p < c, (r, c) -> r + c) => [1] Stream.of(1, 2).collapse((p, c) -> p < c, (r, c) -> r + c) => [3] Stream.of(1, 2, 3).collapse((p, c) -> p < c, (r, c) -> r + c) => [6] Stream.of(1, 2, 3, 3, 2, 1).collapse((p, c) -> p < c, (r, c) -> r + c) => [6, 3, 2, 1]
This method only runs sequentially, even in parallel stream.- Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.mergeFunction
-- Returns:
-
collapse
@SequentialOnly @IntermediateOp public abstract <U> Stream<U> collapse(BiPredicate<? super T, ? super T> collapsible, U init, BiFunction<U, ? super T, U> op) - Type Parameters:
U
-- Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.init
- is used byop
to generate the first result value in the series.op
-- Returns:
-
collapse
@SequentialOnly @IntermediateOp public abstract <R> Stream<R> collapse(BiPredicate<? super T, ? super T> collapsible, Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) - Type Parameters:
R
-- Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.supplier
-accumulator
-- Returns:
-
collapse
@SequentialOnly @IntermediateOp public abstract <R,A> Stream<R> collapse(BiPredicate<? super T, ? super T> collapsible, Collector<? super T, A, R> collector) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.Example:
Stream.of(new Integer[0]).collapse((p, c) -> p < c, Collectors.summingInt(Fn.unboxI())) => [] Stream.of(1).collapse((p, c) -> p < c, Collectors.summingInt(Fn.unboxI())) => [1] Stream.of(1, 2).collapse((p, c) -> p < c, Collectors.summingInt(Fn.unboxI())) => [3] Stream.of(1, 2, 3).collapse((p, c) -> p < c, Collectors.summingInt(Fn.unboxI())) => [6] Stream.of(1, 2, 3, 3, 2, 1).collapse((p, c) -> p < c, Collectors.summingInt(Fn.unboxI())) => [6, 3, 2, 1]
This method only runs sequentially, even in parallel stream.- Parameters:
collapsible
- test the current element with its previous element. The first parameter is the previous element of current element, the second parameter is the current element.collector
-- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract Stream<Stream<T>> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible) - Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible, Supplier<? extends C> supplier) - Type Parameters:
C
-- Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.supplier
-- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible, BiFunction<? super T, ? super T, T> mergeFunction) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.Example:
Stream.of(new Integer[0]).collapse((f, p, c) -> f < c, (r, c) -> r + c) => [] Stream.of(1).collapse((f, p, c) -> f < c, (r, c) -> r + c) => [1] Stream.of(1, 2).collapse((f, p, c) -> f < c, (r, c) -> r + c) => [3] Stream.of(1, 2, 3).collapse((f, p, c) -> f < c, (r, c) -> r + c) => [6] Stream.of(1, 2, 3, 3, 2, 1).collapse((f, p, c) -> f < c, (r, c) -> r + c) => [11, 1]
This method only runs sequentially, even in parallel stream.- Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.mergeFunction
-- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract <U> Stream<U> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible, U init, BiFunction<U, ? super T, U> op) - Type Parameters:
U
-- Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.init
- is used byop
to generate the first result value in the series.op
-- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract <R> Stream<R> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible, Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) - Type Parameters:
R
-- Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.supplier
-accumulator
-- Returns:
-
collapse
@Beta @SequentialOnly @IntermediateOp public abstract <R,A> Stream<R> collapse(TriPredicate<? super T, ? super T, ? super T> collapsible, Collector<? super T, A, R> collector) Merge series of adjacent elements which satisfy the given predicate using the merger function and return a new stream.Example:
Stream.of(new Integer[0]).collapse((f, p, c) -> f < c, Collectors.summingInt(Fn.unboxI())) => [] Stream.of(1).collapse((f, p, c) -> f < c, Collectors.summingInt(Fn.unboxI())) => [1] Stream.of(1, 2).collapse((f, p, c) -> f < c, Collectors.summingInt(Fn.unboxI())) => [3] Stream.of(1, 2, 3).collapse((f, p, c) -> f < c, Collectors.summingInt(Fn.unboxI())) => [6] Stream.of(1, 2, 3, 3, 2, 1).collapse((f, p, c) -> f < c, Collectors.summingInt(Fn.unboxI())) => [11, 1]
This method only runs sequentially, even in parallel stream.- Parameters:
collapsible
- test the current element with the first element and previous element in the series. The first parameter is the first element of this series, the second parameter is the previous element and the third parameter is the current element.collector
-- Returns:
-
scan
@SequentialOnly @IntermediateOp public abstract Stream<T> scan(BiFunction<? super T, ? super T, T> accumulator) Returns aStream
produced by iterative application of a accumulation function to an initial elementinit
and next element of the current stream. Produces aStream
consisting ofinit
,acc(init, value1)
,acc(acc(init, value1), value2)
, etc.This is an intermediate operation.
Example:
Stream.of(new Integer[0]).scan((r, c) -> r + c) => [] Stream.of(1).scan((r, c) -> r + c) => [1] Stream.of(1, 2).scan((r, c) -> r + c) => [1, 3] Stream.of(1, 2, 3).scan((r, c) -> r + c) => [1, 3, 6] Stream.of(1, 2, 3, 3, 2, 1).scan((r, c) -> r + c) => [1, 3, 6, 9, 11, 12]
This method only runs sequentially, even in parallel stream.- Parameters:
accumulator
- the accumulation function- Returns:
-
scan
@SequentialOnly @IntermediateOp public abstract <U> Stream<U> scan(U init, BiFunction<U, ? super T, U> accumulator) Returns aStream
produced by iterative application of a accumulation function to an initial elementinit
and next element of the current stream. Produces aStream
consisting ofinit
,acc(init, value1)
,acc(acc(init, value1), value2)
, etc.This is an intermediate operation.
Example:
Stream.of(new Integer[0]).scan(10, (r, c) -> r + c) => [] Stream.of(1).scan(10, (r, c) -> r + c) => [11] Stream.of(1, 2).scan(10, (r, c) -> r + c) => [11, 13] Stream.of(1, 2, 3).scan(10, (r, c) -> r + c) => [11, 13, 16] Stream.of(1, 2, 3, 3, 2, 1).scan(10, (r, c) -> r + c) => [11, 13, 16, 19, 21, 22]
This method only runs sequentially, even in parallel stream.- Parameters:
init
- the initial value. it's only used once byaccumulator
to calculate the fist element in the returned stream. It will be ignored if this stream is empty and won't be the first element of the returned stream.accumulator
- the accumulation function- Returns:
-
scan
@SequentialOnly @IntermediateOp public abstract <U> Stream<U> scan(U init, BiFunction<U, ? super T, U> accumulator, boolean initIncluded) - Parameters:
init
-accumulator
-initIncluded
-- Returns:
-
splitToSet
Returns Stream of Stream with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
This method only runs sequentially, even in parallel stream.- Parameters:
chunkSize
- the desired size of each sub sequence (the last may be smaller).- Returns:
-
split
@SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> split(int chunkSize, IntFunction<? extends C> collectionSupplier) Returns Stream of Stream with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
This method only runs sequentially, even in parallel stream.- Parameters:
chunkSize
- the desired size of each sub sequence (the last may be smaller).collectionSupplier
-- Returns:
-
split
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> split(int chunkSize, Collector<? super T, A, R> collector) - Parameters:
chunkSize
- the desired size of each sub sequence (the last may be smaller).collector
-- Returns:
-
splitToSet
@SequentialOnly @IntermediateOp public abstract Stream<Set<T>> splitToSet(Predicate<? super T> predicate) -
split
@SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> split(Predicate<? super T> predicate, Supplier<? extends C> collectionSupplier) -
split
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> split(Predicate<? super T> predicate, Collector<? super T, A, R> collector) -
splitAt
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> splitAt(int where, Collector<? super T, A, R> collector) Split the stream into two pieces atwhere
turns tofalse
. The first piece will be loaded into memory.- Type Parameters:
A
-R
-- Parameters:
where
-collector
-- Returns:
-
splitAt
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> splitAt(Predicate<? super T> where, Collector<? super T, A, R> collector) Split the stream into two pieces atwhere
turns tofalse
. The first piece will be loaded into memory.- Type Parameters:
A
-R
-- Parameters:
where
-collector
-- Returns:
-
slidingToSet
- Parameters:
windowSize
-- Returns:
- See Also:
-
slidingToSet
@SequentialOnly @IntermediateOp public abstract Stream<Set<T>> slidingToSet(int windowSize, int increment) - Parameters:
windowSize
-increment
-- Returns:
- See Also:
-
sliding
@SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> sliding(int windowSize, IntFunction<? extends C> collectionSupplier) -
sliding
@SequentialOnly @IntermediateOp public abstract <C extends Collection<T>> Stream<C> sliding(int windowSize, int increment, IntFunction<? extends C> collectionSupplier) -
sliding
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> sliding(int windowSize, Collector<? super T, A, R> collector) -
sliding
@SequentialOnly @IntermediateOp public abstract <A,R> Stream<R> sliding(int windowSize, int increment, Collector<? super T, A, R> collector) -
intersperse
Stream.of(1).intersperse(9) --> [1]
Stream.of(1, 2, 3).intersperse(9) --> [1, 9, 2, 9, 3]
This method only runs sequentially, even in parallel stream.- Parameters:
delimiter
-- Returns:
-
distinct
@ParallelSupported @IntermediateOp @TerminalOpTriggered public Stream<T> distinct(BinaryOperator<T> mergeFunction) Distinct and merge duplicated elements.- Parameters:
mergeFunction
-- Returns:
- See Also:
-
distinct
@SequentialOnly @IntermediateOp @TerminalOpTriggered public Stream<T> distinct(Predicate<? super Long> occurrencesFilter) Distinct and filter by occurrences.- Parameters:
occurrencesFilter
-- Returns:
-
distinctBy
@ParallelSupported @IntermediateOp public abstract Stream<T> distinctBy(Function<? super T, ?> keyMapper) Distinct by the value mapped fromkeyMapper
- Parameters:
keyMapper
- don't change value of the input parameter.- Returns:
-
distinctBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public <K> Stream<T> distinctBy(Function<? super T, K> keyMapper, BinaryOperator<T> mergeFunction) Distinct and merge duplicated elements.- Parameters:
keyMapper
-mergeFunction
-- Returns:
- See Also:
-
distinctBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public <K> Stream<T> distinctBy(Function<? super T, K> keyMapper, Predicate<? super Long> occurrencesFilter) Distinct and filter by occurrences.- Parameters:
keyMapper
-occurrencesFilter
-- Returns:
- See Also:
-
sorted
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> sorted(Comparator<? super T> comparator) -
sortedBy
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> sortedBy(Function<? super T, ? extends Comparable> keyMapper) -
sortedByInt
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> sortedByInt(ToIntFunction<? super T> keyMapper) -
sortedByLong
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> sortedByLong(ToLongFunction<? super T> keyMapper) -
sortedByDouble
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> sortedByDouble(ToDoubleFunction<? super T> keyMapper) -
reverseSorted
@ParallelSupported @IntermediateOp @TerminalOpTriggered public abstract Stream<T> reverseSorted(Comparator<? super T> comparator) -
top
This method only runs sequentially, even in parallel stream.- Parameters:
n
-- Returns:
-
top
@SequentialOnly @IntermediateOp public abstract Stream<T> top(int n, Comparator<? super T> comparator)
This method only runs sequentially, even in parallel stream.- Parameters:
n
-comparator
-- Returns:
-
skipRange
@SequentialOnly @IntermediateOp public abstract Stream<T> skipRange(int startInclusive, int endExclusive) Skip the range: [fromIndexInclusive, fromIndexInclusive]- Parameters:
fromIndexInclusive
-toIndexExclusive
-- Returns:
-
skipNull
-
skipLast
A queue with size up ton
will be maintained to filter out the lastn
elements. It may causeout of memory error
ifn
is big enough.
This method only runs sequentially, even in parallel stream.- Parameters:
n
-- Returns:
-
last
A queue with size up ton
will be maintained to filter out the lastn
elements. It may causeout of memory error
ifn
is big enough.
All the elements will be loaded to get the lastn
elements and the Stream will be closed after that, if a terminal operation is triggered.- Parameters:
n
-- Returns:
-
rateLimited
- Returns:
- See Also:
-
peekFirst
-
peekLast
-
peekIf
@Beta @IntermediateOp public Stream<T> peekIf(Predicate<? super T> predicate, Consumer<? super T> action) - Parameters:
predicate
-action
-- Returns:
-
peekIf
@Beta @IntermediateOp public Stream<T> peekIf(BiPredicate<? super T, ? super Long> predicate, Consumer<? super T> action) - Parameters:
predicate
- The first parameter is the element. The second parameter is the count of iterated elements, starts with 1.action
-- Returns:
-
onErrorContinue
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorContinue(Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
errorConsumer
-- Returns:
-
onErrorContinue
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorContinue(Class<? extends Throwable> type, Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
type
-errorConsumer
-- Returns:
-
onErrorContinue
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorContinue(Predicate<? super Throwable> errorPredicate, Consumer<? super Throwable> errorConsumer) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
errorPredicate
-errorConsumer
-- Returns:
-
onErrorContinue
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorContinue(Predicate<? super Throwable> errorPredicate, Consumer<? super Throwable> errorConsumer, int maxErrorCountToStop) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
errorPredicate
-errorConsumer
-maxErrorCountToStop
-- Returns:
-
onErrorReturn
This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
fallbackValue
-- Returns:
-
onErrorReturn
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorReturn(Class<? extends Throwable> type, T fallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
type
-fallbackValue
-- Returns:
-
onErrorReturn
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorReturn(Predicate<? super Throwable> predicate, T fallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
predicate
-fallbackValue
-- Returns:
-
onErrorReturn
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorReturn(Predicate<? super Throwable> predicate, Supplier<? extends T> supplierForFallbackValue) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
predicate
-supplierForFallbackValue
-- Returns:
-
onErrorReturn
@Beta @SequentialOnly @IntermediateOp public abstract Stream<T> onErrorReturn(Predicate<? super Throwable> predicate, Function<? super Throwable, ? extends T> mapperForFallbackValue, int maxErrorCountToStop) This method should be only applied sequentialStream
and whose up-streams are sequentialStreams
as well. Because error happening in the operations executed by parallel stream will stop iteration on that , so the down-streams won't be able to continue.- Parameters:
predicate
-mapperForFallbackValue
-maxErrorCountToStop
-- Returns:
-
onErrorStop
- Returns:
-
forEach
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEach(Throwables.Consumer<? super T, E> action) throws E- Throws:
E extends Exception
-
forEachIndexed
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachIndexed(Throwables.IndexedConsumer<? super T, E> action) throws E- Throws:
E extends Exception
-
forEachUntil
@Beta @ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachUntil(Throwables.BiConsumer<? super T, MutableBoolean, throws EE> action) - Type Parameters:
E
-- Parameters:
action
- the second parameter is a flag to break the for-each loop. Set it totrue
to break the loop if you don't want to continue theaction
. Iteration on this stream will also be stopped when this flag is set totrue
.- Throws:
E
-
forEachUntil
@Beta @ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachUntil(MutableBoolean flagToBreak, Throwables.Consumer<? super T, E> action) throws E- Type Parameters:
E
-- Parameters:
flagToBreak
- a flag to break the for-each loop. Set it totrue
to break the loop if you don't want to continue theaction
. Iteration on this stream will also be stopped when this flag is set totrue
.action
-- Throws:
E
-
forEach
@ParallelSupported @TerminalOp public abstract <E extends Exception,E2 extends Exception> void forEach(Throwables.Consumer<? super T, E> action, Throwables.Runnable<E2> onComplete) throws E, E2 -
forEach
@ParallelSupported @TerminalOp public abstract <U,E extends Exception, void forEachE2 extends Exception> (Throwables.Function<? super T, ? extends Collection<? extends U>, throws E, E2E> flatMapper, Throwables.BiConsumer<? super T, ? super U, E2> action) -
forEach
@ParallelSupported @TerminalOp public abstract <T2,T3, void forEachE extends Exception, E2 extends Exception, E3 extends Exception> (Throwables.Function<? super T, ? extends Collection<T2>, throws E, E2, E3E> flatMapper, Throwables.Function<? super T2, ? extends Collection<T3>, E2> flatMapper2, Throwables.TriConsumer<? super T, ? super T2, ? super T3, E3> action) -
forEachPair
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachPair(Throwables.BiConsumer<? super T, ? super T, throws EE> action) - Throws:
E extends Exception
-
forEachPair
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachPair(Throwables.BiConsumer<? super T, ? super T, throws EE> action, int increment) Slide withwindowSize = 2
and the specifiedincrement
, thenconsume
by the specifiedmapper
.- Parameters:
mapper
-increment
-- Throws:
E extends Exception
-
forEachTriple
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachTriple(Throwables.TriConsumer<? super T, ? super T, throws E? super T, E> action) - Throws:
E extends Exception
-
forEachTriple
@ParallelSupported @TerminalOp public abstract <E extends Exception> void forEachTriple(Throwables.TriConsumer<? super T, ? super T, throws E? super T, E> action, int increment) Slide withwindowSize = 3
and the specifiedincrement
, thenconsume
by the specifiedmapper
.- Parameters:
mapper
-increment
-- Throws:
E extends Exception
-
anyMatch
@ParallelSupported @TerminalOp public abstract <E extends Exception> boolean anyMatch(Throwables.Predicate<? super T, E> predicate) throws E- Throws:
E extends Exception
-
allMatch
@ParallelSupported @TerminalOp public abstract <E extends Exception> boolean allMatch(Throwables.Predicate<? super T, E> predicate) throws E- Throws:
E extends Exception
-
noneMatch
@ParallelSupported @TerminalOp public abstract <E extends Exception> boolean noneMatch(Throwables.Predicate<? super T, E> predicate) throws E- Throws:
E extends Exception
-
nMatch
@ParallelSupported @TerminalOp public abstract <E extends Exception> boolean nMatch(long atLeast, long atMost, Throwables.Predicate<? super T, E> predicate) throws E- Throws:
E extends Exception
-
findFirst
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> findFirst(Throwables.Predicate<? super T, E> predicate) throws EReturns the first element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned.- Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
-
findLast
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> findLast(Throwables.Predicate<? super T, E> predicate) throws EReturns the last element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned.
Consider using:stream.reversed().findFirst(predicate)
for better performance if possible.- Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
-
findAny
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> findAny(Throwables.Predicate<? super T, E> predicate) throws EReturns any element matched bypredicateForFirst
if found, Otherwise an emptyOptional<T>
will be returned. It's same asfindFirst
and always returns the first element matched bypredicateForFirst
if found in sequential stream. In parallel stream, it may have better performance thanfindFirst
.- Type Parameters:
E
-- Parameters:
predicate
-- Returns:
- Throws:
E
-
findFirstOrAny
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> findFirstOrAny(Throwables.Predicate<? super T, E> predicateForFirst) throws EReturns the first element matched bypredicateForFirst
if found or the first element if this stream is not empty Otherwise an emptyOptional<T>
will be returned.- Type Parameters:
E
-- Parameters:
predicateForFirst
-- Returns:
- Throws:
E
-
findFirstOrAny
@ParallelSupported @TerminalOp public abstract <E extends Exception,E2 extends Exception> u.Optional<T> findFirstOrAny(Throwables.Predicate<? super T, E> predicateForFirst, Throwables.Predicate<? super T, throws E, E2E2> predicateForAny) Returns the first element matched bypredicateForFirst
if found or any element matched bypredicateForAny
(If this is a sequential stream, it will always be the first element matched bypredicateForAny
). Otherwise an emptyOptional<T>
will be returned.- Type Parameters:
E
-E2
-- Parameters:
predicateForFirst
-predicateForAny
-- Returns:
- Throws:
E
E2
-
findFirstOrLast
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> findFirstOrLast(Throwables.Predicate<? super T, E> predicateForFirst) throws EReturns the first element matched bypredicateForFirst
if found or the last element if this stream is not empty Otherwise an emptyOptional<T>
will be returned.- Type Parameters:
E
-- Parameters:
predicateForFirst
-- Returns:
- Throws:
E
-
findFirstOrLast
@Beta @SequentialOnly @TerminalOp public abstract <E extends Exception,E2 extends Exception> u.Optional<T> findFirstOrLast(Throwables.Predicate<? super T, E> predicateForFirst, Throwables.Predicate<? super T, throws E, E2E2> predicateForLast) -
findFirstOrLast
@Beta @SequentialOnly @TerminalOp public abstract <U,E extends Exception, u.Optional<T> findFirstOrLastE2 extends Exception> (U init, Throwables.BiPredicate<? super T, ? super U, throws E, E2E> predicateForFirst, Throwables.BiPredicate<? super T, ? super U, E2> predicateForLast)
This method only runs sequentially, even in parallel stream. -
findFirstOrLast
@Beta @SequentialOnly @TerminalOp public abstract <U,E extends Exception, u.Optional<T> findFirstOrLastE2 extends Exception> (Function<? super T, U> preFunc, Throwables.BiPredicate<? super T, throws E, E2? super U, E> predicateForFirst, Throwables.BiPredicate<? super T, ? super U, E2> predicateForLast)
This method only runs sequentially, even in parallel stream. -
containsAll
-
containsAll
-
containsAny
-
containsAny
-
toArray
-
toImmutableMap
@ParallelSupported @TerminalOp public <K,V, ImmutableMap<K,E extends Exception, E2 extends Exception> V> toImmutableMap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) -
toImmutableMap
@ParallelSupported @TerminalOp public <K,V, ImmutableMap<K,E extends Exception, E2 extends Exception> V> toImmutableMap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction) -
toMap
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,E extends Exception, E2 extends Exception> V> toMap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) -
toMap
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,E extends Exception, E2 extends Exception> V> toMap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction) -
toMap
@ParallelSupported @TerminalOp public abstract <K,V, M toMapM extends Map<K, V>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) -
toMap
@ParallelSupported @TerminalOp public abstract <K,V, M toMapM extends Map<K, V>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, BinaryOperator<V> mergeFunction, Supplier<? extends M> mapFactory) -
toMap
@Deprecated @ParallelSupported @TerminalOp public final <K,A, Map<K,D, E extends Exception> D> toMap(Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Collector<? super T, A, D> downstream) Deprecated.replaced bygroupTo
- Parameters:
keyMapper
-downstream
-- Returns:
- Throws:
E extends Exception
- See Also:
-
toMap
@Deprecated @ParallelSupported @TerminalOp public final <K,A, M toMapD, M extends Map<K, D>, E extends Exception> (Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) Deprecated.replaced bygroupTo
- Parameters:
keyMapper
-downstream
-mapFactory
-- Returns:
- Throws:
E extends Exception
- See Also:
-
toMap
@Deprecated @ParallelSupported @TerminalOp public final <K,V, Map<K,A, D, E extends Exception, E2 extends Exception> D> toMap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) Deprecated.replaced bygroupTo
-
toMap
@Deprecated @ParallelSupported @TerminalOp public final <K,V, M toMapA, D, M extends Map<K, D>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) Deprecated.replaced bygroupTo
-
groupTo
@ParallelSupported @TerminalOp public abstract <K,E extends Exception> Map<K,List<T>> groupTo(Throwables.Function<? super T, ? extends K, throws EE> keyMapper) - Parameters:
keyMapper
-- Returns:
- Throws:
E extends Exception
- See Also:
-
groupTo
@ParallelSupported @TerminalOp public abstract <K,M extends Map<K, M groupToList<T>>, E extends Exception> (Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Supplier<? extends M> mapFactory) - Parameters:
keyMapper
-mapFactory
-- Returns:
- Throws:
E extends Exception
- See Also:
-
groupTo
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,E extends Exception, E2 extends Exception> List<V>> groupTo(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) -
groupTo
@ParallelSupported @TerminalOp public abstract <K,V, M groupToM extends Map<K, List<V>>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) -
groupTo
@ParallelSupported @TerminalOp public abstract <K,A, Map<K,D, E extends Exception> D> groupTo(Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Collector<? super T, A, D> downstream) - Parameters:
keyMapper
-downstream
-- Returns:
- Throws:
E extends Exception
- See Also:
-
groupTo
@ParallelSupported @TerminalOp public abstract <K,A, M groupToD, M extends Map<K, D>, E extends Exception> (Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) - Parameters:
keyMapper
-downstream
-mapFactory
-- Returns:
- Throws:
E extends Exception
- See Also:
-
groupTo
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,A, D, E extends Exception, E2 extends Exception> D> groupTo(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) -
groupTo
@ParallelSupported @TerminalOp public abstract <K,V, M groupToA, D, M extends Map<K, D>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) -
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,E extends Exception> Map<K,List<T>> flatGroupTo(Throwables.Function<? super T, ? extends Collection<? extends K>, throws EE> flatKeyMapper) - Type Parameters:
K
-E
-- Parameters:
flatKeyMapper
-- Returns:
- Throws:
E
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,M extends Map<K, M flatGroupToList<T>>, E extends Exception> (Throwables.Function<? super T, ? extends Collection<? extends K>, throws EE> flatKeyMapper, Supplier<? extends M> mapFactory) - Type Parameters:
K
-M
-E
-- Parameters:
flatKeyMapper
-mapFactory
-- Returns:
- Throws:
E
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,E extends Exception, E2 extends Exception> List<V>> flatGroupTo(Throwables.Function<? super T, ? extends Collection<? extends K>, throws E, E2E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper) - Type Parameters:
K
-V
-E
-E2
-- Parameters:
flatKeyMapper
-valueMapper
-- Returns:
- Throws:
E
E2
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,V, M flatGroupToM extends Map<K, List<V>>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends Collection<? extends K>, throws E, E2E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) - Type Parameters:
K
-V
-M
-E
-E2
-- Parameters:
flatKeyMapper
-valueMapper
-mapFactory
-- Returns:
- Throws:
E
E2
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,A, Map<K,D, E extends Exception> D> flatGroupTo(Throwables.Function<? super T, ? extends Collection<? extends K>, throws EE> flatKeyMapper, Collector<? super T, A, D> downstream) - Type Parameters:
K
-A
-D
-E
-- Parameters:
flatKeyMapper
-downstream
-- Returns:
- Throws:
E
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,A, M flatGroupToD, M extends Map<K, D>, E extends Exception> (Throwables.Function<? super T, ? extends Collection<? extends K>, throws EE> flatKeyMapper, Collector<? super T, A, D> downstream, Supplier<? extends M> mapFactory) - Type Parameters:
K
-A
-D
-M
-E
-- Parameters:
flatKeyMapper
-downstream
-mapFactory
-- Returns:
- Throws:
E
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,V, Map<K,A, D, E extends Exception, E2 extends Exception> D> flatGroupTo(Throwables.Function<? super T, ? extends Collection<? extends K>, throws E, E2E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream) - Type Parameters:
K
-V
-A
-D
-E
-E2
-- Parameters:
flatKeyMapper
-valueMapper
-downstream
-- Returns:
- Throws:
E
E2
-
flatGroupTo
@ParallelSupported @TerminalOp public abstract <K,V, M flatGroupToA, D, M extends Map<K, D>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends Collection<? extends K>, throws E, E2E> flatKeyMapper, Throwables.BiFunction<? super K, ? super T, ? extends V, E2> valueMapper, Collector<? super V, A, D> downstream, Supplier<? extends M> mapFactory) - Type Parameters:
K
-V
-A
-D
-M
-E
-E2
-- Parameters:
flatKeyMapper
-valueMapper
-downstream
-mapFactory
-- Returns:
- Throws:
E
E2
-
partitionTo
@ParallelSupported @TerminalOp public abstract <E extends Exception> Map<Boolean,List<T>> partitionTo(Throwables.Predicate<? super T, E> predicate) throws E- Parameters:
predicate
-- Returns:
- Throws:
E extends Exception
- See Also:
-
partitionTo
@ParallelSupported @TerminalOp public abstract <A,D, Map<Boolean,E extends Exception> D> partitionTo(Throwables.Predicate<? super T, E> predicate, Collector<? super T, throws EA, D> downstream) - Parameters:
predicate
-downstream
-- Returns:
- Throws:
E extends Exception
- See Also:
-
toMultimap
@ParallelSupported @TerminalOp public abstract <K,E extends Exception> ListMultimap<K,T> toMultimap(Throwables.Function<? super T, ? extends K, throws EE> keyMapper) - Parameters:
keyMapper
-- Returns:
- Throws:
E extends Exception
- See Also:
-
toMultimap
@ParallelSupported @TerminalOp public abstract <K,V extends Collection<T>, M toMultimapM extends Multimap<K, T, V>, E extends Exception> (Throwables.Function<? super T, ? extends K, throws EE> keyMapper, Supplier<? extends M> mapFactory) - Parameters:
keyMapper
-mapFactory
-- Returns:
- Throws:
E extends Exception
- See Also:
-
toMultimap
@ParallelSupported @TerminalOp public abstract <K,V, ListMultimap<K,E extends Exception, E2 extends Exception> V> toMultimap(Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper) -
toMultimap
@ParallelSupported @TerminalOp public abstract <K,V, M toMultimapC extends Collection<V>, M extends Multimap<K, V, C>, E extends Exception, E2 extends Exception> (Throwables.Function<? super T, ? extends K, throws E, E2E> keyMapper, Throwables.Function<? super T, ? extends V, E2> valueMapper, Supplier<? extends M> mapFactory) -
toDataSet
The first row will be used as column names if its type is array or list, or obtain the column names from first row if its type is entity or map.- Returns:
- Throws:
E
-
toDataSet
If the specifiedcolumnNames
is null or empty, the first row will be used as column names if its type is array or list, or obtain the column names from first row if its type is entity or map.- Parameters:
columnNames
-- Returns:
- Throws:
E
-
join
-
foldLeft
@SequentialOnly @TerminalOp public abstract <E extends Exception> u.Optional<T> foldLeft(Throwables.BinaryOperator<T, E> accumulator) throws EThis method will always run sequentially, even in parallel stream.- Type Parameters:
E
-- Parameters:
accumulator
-- Returns:
- Throws:
E
- See Also:
-
#reduce(BinaryOperator)
-
foldLeft
@SequentialOnly @TerminalOp public abstract <U,E extends Exception> U foldLeft(U identity, Throwables.BiFunction<U, ? super T, throws EU, E> accumulator) This method will always run sequentially, even in parallel stream.- Type Parameters:
U
-E
-- Parameters:
identity
-accumulator
-- Returns:
- Throws:
E
- See Also:
-
#reduce(Object, BiFunction, BinaryOperator)
-
foldRight
@SequentialOnly @TerminalOp public abstract <E extends Exception> u.Optional<T> foldRight(Throwables.BinaryOperator<T, E> accumulator) throws EThis method will always run sequentially, even in parallel stream.- Type Parameters:
E
-- Parameters:
accumulator
-- Returns:
- Throws:
E
- See Also:
-
#reduce(BinaryOperator)
-
foldRight
@SequentialOnly @TerminalOp public abstract <U,E extends Exception> U foldRight(U identity, Throwables.BiFunction<U, ? super T, throws EU, E> accumulator) This method will always run sequentially, even in parallel stream.- Type Parameters:
U
-E
-- Parameters:
identity
-accumulator
-- Returns:
- Throws:
E
- See Also:
-
#reduce(Object, BiFunction, BinaryOperator)
-
reduce
@ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> reduce(Throwables.BinaryOperator<T, E> accumulator) throws E- Parameters:
accumulator
-- Returns:
- Throws:
E extends Exception
- See Also:
-
reduce
@ParallelSupported @TerminalOp public <E extends Exception> T reduce(T identity, Throwables.BinaryOperator<T, E> accumulator) throws E- Parameters:
identity
-accumulator
-- Returns:
- Throws:
E extends Exception
- See Also:
-
reduce
@ParallelSupported @TerminalOp public abstract <U,E extends Exception> U reduce(U identity, Throwables.BiFunction<U, ? super T, throws EU, E> accumulator, Throwables.BinaryOperator<U, E> combiner) - Type Parameters:
U
-- Parameters:
identity
-accumulator
-combiner
-- Returns:
- Throws:
E extends Exception
- See Also:
-
reduceUntil
@Beta @ParallelSupported @TerminalOp public abstract <E extends Exception> u.Optional<T> reduceUntil(Throwables.BinaryOperator<T, E> accumulator, Throwables.Predicate<? super T, throws EE> conditionToBreak) - Parameters:
accumulator
-conditionToBreak
- the input parameter is the return value ofaccumulator
, not the element from this Stream. Returnstrue
to break the loop if you don't want to continue theaction
. Iteration on this stream will also be stopped when this flag is set totrue
.- Returns:
- Throws:
E extends Exception
- See Also:
-
reduceUntil
@Beta @ParallelSupported @TerminalOp public <E extends Exception> T reduceUntil(T identity, Throwables.BinaryOperator<T, E> accumulator, Throwables.Predicate<? super T, throws EE> conditionToBreak) - Parameters:
identity
-accumulator
-conditionToBreak
- the input parameter is the return value ofaccumulator
, not the element from this Stream. Returnstrue
to break the loop if you don't want to continue theaction
. Iteration on this stream will also be stopped when this flag is set totrue
.- Returns:
- Throws:
E extends Exception
- See Also:
-
reduceUntil
@Beta @ParallelSupported @TerminalOp public abstract <U,E extends Exception> U reduceUntil(U identity, Throwables.BiFunction<U, ? super T, throws EU, E> accumulator, Throwables.BinaryOperator<U, E> combiner, Throwables.Predicate<? super U, E> conditionToBreak) - Type Parameters:
U
-- Parameters:
identity
-accumulator
-combiner
-conditionToBreak
- the input parameter is the return value ofaccumulator
, not the element from this Stream. Returnstrue
to break the loop if you don't want to continue theaction
. Iteration on this stream will also be stopped when this flag is set totrue
.- Returns:
- Throws:
E extends Exception
- See Also:
-
collect
@ParallelSupported @TerminalOp public abstract <R> R collect(Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator, BiConsumer<R, R> combiner) - Type Parameters:
R
- ifR
isMap/Collection/StringBuilder/Multiset/LongMultiset/Multimap/BooleanList/IntList/.../DoubleList
, It's not required to specifiedcombiner
. Otherwise,combiner
must be specified.- Parameters:
supplier
-accumulator
-combiner
-- Returns:
- See Also:
-
collect
@ParallelSupported @TerminalOp public abstract <R> R collect(Supplier<R> supplier, BiConsumer<? super R, ? super T> accumulator) - Type Parameters:
R
- ifR
isMap/Collection/StringBuilder/Multiset/LongMultiset/Multimap/BooleanList/IntList/.../DoubleList
, It's not required to specifiedcombiner
. Otherwise,combiner
must be specified.- Parameters:
supplier
-accumulator
-- Returns:
- See Also:
-
collect
-
collectAndThen
@ParallelSupported @TerminalOp public abstract <R,A, RR collectAndThenRR, E extends Exception> (Collector<? super T, A, throws ER> downstream, Throwables.Function<? super R, RR, E> func) - Throws:
E extends Exception
-
toListAndThen
@SequentialOnly @TerminalOp public abstract <R,E extends Exception> R toListAndThen(Throwables.Function<? super List<T>, R, throws EE> func) - Throws:
E extends Exception
-
toSetAndThen
@SequentialOnly @TerminalOp public abstract <R,E extends Exception> R toSetAndThen(Throwables.Function<? super Set<T>, R, throws EE> func) - Throws:
E extends Exception
-
toCollectionAndThen
@SequentialOnly @TerminalOp public abstract <R,CC extends Collection<T>, R toCollectionAndThenE extends Exception> (Supplier<? extends CC> supplier, Throwables.Function<? super CC, R, throws EE> func) - Throws:
E extends Exception
-
min
-
minBy
@ParallelSupported @TerminalOp public u.Optional<T> minBy(Function<? super T, ? extends Comparable> keyMapper) -
minAll
-
max
-
maxBy
@ParallelSupported @TerminalOp public u.Optional<T> maxBy(Function<? super T, ? extends Comparable> keyMapper) -
maxAll
-
kthLargest
@ParallelSupported @TerminalOp public abstract u.Optional<T> kthLargest(int k, Comparator<? super T> comparator) - Parameters:
k
-comparator
-- Returns:
- Optional.empty() if there is no element or count less than k, otherwise the kth largest element.
-
sumInt
-
sumLong
-
sumDouble
-
averageInt
@ParallelSupported @TerminalOp public abstract u.OptionalDouble averageInt(ToIntFunction<? super T> mapper) -
averageLong
@ParallelSupported @TerminalOp public abstract u.OptionalDouble averageLong(ToLongFunction<? super T> mapper) -
averageDouble
@ParallelSupported @TerminalOp public abstract u.OptionalDouble averageDouble(ToDoubleFunction<? super T> mapper) -
percentiles
@SequentialOnly @TerminalOp public abstract u.Optional<Map<Percentage,T>> percentiles(Comparator<? super T> comparator) -
hasDuplicates
-
combinations
Stream.of(1, 2, 3).combinations().forEach(Fn.println()); // output [] [1] [2] [3] [1, 2] [1, 3] [2, 3] [1, 2, 3]
- Returns:
-
combinations
Stream.of(1, 2, 3).combinations(2).forEach(Fn.println()); // output [1, 2] [1, 3] [2, 3]
- Parameters:
len
-- Returns:
-
combinations
@SequentialOnly @IntermediateOp public abstract Stream<List<T>> combinations(int len, boolean repeat) It's same asN.cartesianProduct(N.repeat(toList(), len))
ifrepeat
istrue
.Stream.of(1, 2, 3).combinations(2, true).forEach(Fn.println()); // output [1, 1] [1, 2] [1, 3] [2, 1] [2, 2] [2, 3] [3, 1] [3, 2] [3, 3]
- Parameters:
len
-repeat
-- Returns:
-
permutations
Stream.of(1, 2, 3).permutations().forEach(Fn.println()); // output [1, 2, 3] [1, 3, 2] [3, 1, 2] [3, 2, 1] [2, 3, 1] [2, 1, 3]
- Returns:
-
orderedPermutations
Stream.of(1, 2, 3).orderedPermutations().forEach(Fn.println()); // output [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1]
- Returns:
-
orderedPermutations
@SequentialOnly @IntermediateOp public abstract Stream<List<T>> orderedPermutations(Comparator<? super T> comparator) -
cartesianProduct
@SequentialOnly @IntermediateOp @SafeVarargs public final Stream<List<T>> cartesianProduct(Collection<? extends T>... cs) -
cartesianProduct
@SequentialOnly @IntermediateOp public abstract Stream<List<T>> cartesianProduct(Collection<? extends Collection<? extends T>> cs) -
intersection
@ParallelSupported @IntermediateOp public abstract <U> Stream<T> intersection(Function<? super T, ? extends U> mapper, Collection<U> c) Intersect with the specified Collection by the values mapped bymapper
.- Parameters:
mapper
-c
-- Returns:
- See Also:
-
difference
@ParallelSupported @IntermediateOp public abstract <U> Stream<T> difference(Function<? super T, ? extends U> mapper, Collection<U> c) Except with the specified Collection by the values mapped bymapper
.- Parameters:
mapper
-c
-- Returns:
- See Also:
-
defaultIfEmpty
- Parameters:
defaultValue
-- Returns:
- See Also:
-
defaultIfEmpty
@SequentialOnly @IntermediateOp public final Stream<T> defaultIfEmpty(Supplier<? extends Stream<T>> supplier) - Parameters:
supplier
-- Returns:
- See Also:
-
prepend
-
prepend
-
append
-
append
-
appendIfEmpty
-
appendIfEmpty
-
rollup
-
buffered
Returns a new Stream with elements from a temporary queue which is filled by reading the elements from this Stream asynchronously with a new thread. Default queue size is 64.
Mostly it's forread-write with different threads
mode.- Returns:
- See Also:
-
buffered
Returns a new Stream with elements from a temporary queue which is filled by reading the elements from this Stream asynchronously with a new thread.
Mostly it's forread-write with different threads
mode.- Parameters:
bufferSize
-- Returns:
- See Also:
-
merge
@Deprecated @SequentialOnly @IntermediateOp public Stream<T> merge(Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) Deprecated.replaced bymergeWith(Stream, BiFunction)
- Parameters:
b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
- See Also:
-
mergeWith
@SequentialOnly @IntermediateOp public abstract Stream<T> mergeWith(Collection<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
mergeWith
@SequentialOnly @IntermediateOp public abstract Stream<T> mergeWith(Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,R> Stream<R> zipWith(Collection<T2> b, BiFunction<? super T, ? super T2, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,R> Stream<R> zipWith(Collection<T2> b, T valueForNoneA, T2 valueForNoneB, BiFunction<? super T, ? super T2, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,T3, Stream<R> zipWithR> (Collection<T2> b, Collection<T3> c, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,T3, Stream<R> zipWithR> (Collection<T2> b, Collection<T3> c, T valueForNoneA, T2 valueForNoneB, T3 valueForNoneC, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,R> Stream<R> zipWith(Stream<T2> b, BiFunction<? super T, ? super T2, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,R> Stream<R> zipWith(Stream<T2> b, T valueForNoneA, T2 valueForNoneB, BiFunction<? super T, ? super T2, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,T3, Stream<R> zipWithR> (Stream<T2> b, Stream<T3> c, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) -
zipWith
@ParallelSupported @IntermediateOp public abstract <T2,T3, Stream<R> zipWithR> (Stream<T2> b, Stream<T3> c, T valueForNoneA, T2 valueForNoneB, T3 valueForNoneC, TriFunction<? super T, ? super T2, ? super T3, R> zipFunction) -
persist
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(String header, String tail, File file) throws IOException - Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.Function<? super T, String, throws IOExceptionIOException> toLine, File file) toCSV:final JSONSerializationConfig jsc = JSC.create().setBracketRootValue(false); final Throwables.Function<? super T, String, IOException> toLine = it -> N.toJSON(it, jsc); stream.persist(toLine, header, outputFile);
- Parameters:
toLine
-file
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.Function<? super T, String, throws IOExceptionIOException> toLine, String header, String tail, File file) - Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.Function<? super T, String, throws IOExceptionIOException> toLine, OutputStream os) - Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.Function<? super T, String, throws IOExceptionIOException> toLine, Writer writer) toCSV:final JSONSerializationConfig jsc = JSC.create().setBracketRootValue(false); final Throwables.Function<? super T, String, IOException> toLine = it -> N.toJSON(it, jsc); stream.persist(toLine, header, outputFile);
- Parameters:
toLine
-writer
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.Function<? super T, String, throws IOExceptionIOException> toLine, String header, String tail, Writer writer) - Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.BiConsumer<? super T, Writer, throws IOExceptionIOException> writeLine, File file) - Parameters:
writeLine
-file
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.BiConsumer<? super T, Writer, throws IOExceptionIOException> writeLine, String header, String tail, File file) - Parameters:
writeLine
-header
-tail
-file
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.BiConsumer<? super T, Writer, throws IOExceptionIOException> writeLine, Writer writer) - Parameters:
writeLine
-writer
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Throwables.BiConsumer<? super T, Writer, throws IOExceptionIOException> writeLine, String header, String tail, Writer writer) - Parameters:
writeLine
-header
-tail
-writer
-- Returns:
- Throws:
IOException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(Connection conn, String insertSQL, int batchSize, int batchInterval, Throwables.BiConsumer<? super T, ? super PreparedStatement, throws SQLExceptionSQLException> stmtSetter) - Parameters:
conn
-insertSQL
-batchSize
-batchInterval
-stmtSetter
-- Returns:
- Throws:
SQLException
-
persist
@SequentialOnly @TerminalOp public abstract long persist(PreparedStatement stmt, int batchSize, int batchInterval, Throwables.BiConsumer<? super T, ? super PreparedStatement, throws SQLExceptionSQLException> stmtSetter) - Parameters:
stmt
-batchSize
-batchInterval
-stmtSetter
-- Returns:
- Throws:
SQLException
-
persistToCSV
Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
file
-- Returns:
- Throws:
IOException
-
persistToCSV
@SequentialOnly @TerminalOp public abstract long persistToCSV(Collection<String> csvHeaders, File file) throws IOException Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
csvHeaders
-file
-- Returns:
- Throws:
IOException
-
persistToCSV
Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
os
-- Returns:
- Throws:
IOException
-
persistToCSV
@SequentialOnly @TerminalOp public abstract long persistToCSV(Collection<String> csvHeaders, OutputStream os) throws IOException Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
csvHeaders
-os
-- Returns:
- Throws:
IOException
-
persistToCSV
Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
writer
-- Returns:
- Throws:
IOException
-
persistToCSV
@SequentialOnly @TerminalOp public abstract long persistToCSV(Collection<String> csvHeaders, Writer writer) throws IOException Each line in the output file/Writer is an array of JSON String without root bracket.- Parameters:
csvHeaders
-writer
-- Returns:
- Throws:
IOException
-
toJdkStream
Remember to close this Stream after the iteration is done, if needed.- Returns:
-
checked
- Type Parameters:
E
-- Parameters:
cls
-- Returns:
-
checked
@Beta @SequentialOnly @IntermediateOp public <E extends Exception> ExceptionalStream<T,E> checked(Class<E> exceptionType) - Type Parameters:
E
-- Parameters:
exceptionType
-- Returns:
-
iterator
Remember to close this Stream after the iteration is done, if needed.- Returns:
-
sps
@Beta @IntermediateOp public <R> Stream<R> sps(int maxThreadNum, int bufferSize, Function<? super Stream<T>, ? extends Stream<? extends R>> op) Temporarily switch the stream to parallel stream for operationop
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> op.apply(s)).sequential()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-bufferSize
-op
-- Returns:
-
spsFilter
Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.
stream().parallel().filter(predicate).sequence()
- Parameters:
predicate
-- Returns:
- See Also:
-
spsMap
Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.
stream().parallel().map(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsFlatMap
@Beta @IntermediateOp public <R> Stream<R> spsFlatMap(Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flatMap(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsFlattMap
@Beta @IntermediateOp public <R> Stream<R> spsFlattMap(Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flattMap(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsOnEach
Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.
stream().parallel().onEach(action).sequence()
- Parameters:
action
-- Returns:
- See Also:
-
spsFilter
Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.
stream().parallel(maxThreadNum).filter(predicate).sequence()
- Parameters:
maxThreadNum
-predicate
-- Returns:
- See Also:
-
spsMap
@Beta @IntermediateOp public <R> Stream<R> spsMap(int maxThreadNum, Function<? super T, ? extends R> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.
stream().parallel(maxThreadNum).map(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsFlatMap
@Beta @IntermediateOp public <R> Stream<R> spsFlatMap(int maxThreadNum, Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel(maxThreadNum).flatMap(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsFlattMap
@Beta @IntermediateOp public <R> Stream<R> spsFlattMap(int maxThreadNum, Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel(maxThreadNum).flattMap(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsOnEach
Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.
stream().parallel(maxThreadNum).onEach(action).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-action
-- Returns:
- See Also:
-
spsFilter
@Beta @IntermediateOp public Stream<T> spsFilter(int maxThreadNum, int bufferSize, Predicate<? super T> predicate) Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> s.filter(predicate)).sequential()
- Parameters:
maxThreadNum
-bufferSize
-predicate
-- Returns:
- See Also:
-
spsMap
@Beta @IntermediateOp public <R> Stream<R> spsMap(int maxThreadNum, int bufferSize, Function<? super T, ? extends R> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> s.map(mapper)).sequential()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-bufferSize
-mapper
-- Returns:
- See Also:
-
spsFlatMap
@Beta @IntermediateOp public <R> Stream<R> spsFlatMap(int maxThreadNum, int bufferSize, Function<? super T, ? extends Stream<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> s.flatMap(mapper)).sequential()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-bufferSize
-mapper
-- Returns:
- See Also:
-
spsFlattMap
@Beta @IntermediateOp public <R> Stream<R> spsFlattMap(int maxThreadNum, int bufferSize, Function<? super T, ? extends Collection<? extends R>> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> s.flattMap(mapper)).sequential()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-bufferSize
-mapper
-- Returns:
- See Also:
-
spsOnEach
@Beta @IntermediateOp public Stream<T> spsOnEach(int maxThreadNum, int bufferSize, Consumer<? super T> action) Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.
split(bufferSize).flatMap(s -> s.onEach(action)).sequential()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-bufferSize
-action
-- Returns:
- See Also:
-
spsFilterE
@Beta @IntermediateOp public Stream<T> spsFilterE(Throwables.Predicate<? super T, ? extends Exception> predicate) Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.
stream().parallel().filterE(predicate).sequence()
- Parameters:
predicate
-- Returns:
- See Also:
-
spsMapE
@Beta @IntermediateOp public <R> Stream<R> spsMapE(Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.
stream().parallel().mapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsFlatMapE
@Beta @IntermediateOp public <R> Stream<R> spsFlatMapE(Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flatMapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsFlattMapE
@Beta @IntermediateOp public <R> Stream<R> spsFlattMapE(Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flattMapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
spsOnEachE
@Beta @IntermediateOp public Stream<T> spsOnEachE(Throwables.Consumer<? super T, ? extends Exception> action) Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.
stream().parallel().onEachE(action).sequence()
- Parameters:
action
-- Returns:
- See Also:
-
spsFilterE
@Beta @IntermediateOp public Stream<T> spsFilterE(int maxThreadNum, Throwables.Predicate<? super T, ? extends Exception> predicate) Temporarily switch the stream to parallel stream for operationfilter
and then switch back to sequence stream.
stream().parallel().filterE(predicate).sequence()
- Parameters:
maxThreadNum
-predicate
-- Returns:
- See Also:
-
spsMapE
@Beta @IntermediateOp public <R> Stream<R> spsMapE(int maxThreadNum, Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationmap
and then switch back to sequence stream.
stream().parallel().mapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsFlatMapE
@Beta @IntermediateOp public <R> Stream<R> spsFlatMapE(int maxThreadNum, Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flatMapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsFlattMapE
@Beta @IntermediateOp public <R> Stream<R> spsFlattMapE(int maxThreadNum, Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) Temporarily switch the stream to parallel stream for operationflatMap
and then switch back to sequence stream.
stream().parallel().flattMapE(mapper).sequence()
- Type Parameters:
R
-- Parameters:
maxThreadNum
-mapper
-- Returns:
- See Also:
-
spsOnEachE
@Beta @IntermediateOp public Stream<T> spsOnEachE(int maxThreadNum, Throwables.Consumer<? super T, ? extends Exception> action) Temporarily switch the stream to parallel stream for operationonEach
and then switch back to sequence stream.
stream().parallel().onEachE(action).sequence()
- Parameters:
maxThreadNum
-action
-- Returns:
- See Also:
-
filterE
@Beta @ParallelSupported @IntermediateOp public Stream<T> filterE(Throwables.Predicate<? super T, ? extends Exception> predicate) - Parameters:
predicate
-- Returns:
- See Also:
-
mapE
@Beta @ParallelSupported @IntermediateOp public <R> Stream<R> mapE(Throwables.Function<? super T, ? extends R, ? extends Exception> mapper) - Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
flatMapE
@Beta @ParallelSupported @IntermediateOp public <R> Stream<R> flatMapE(Throwables.Function<? super T, ? extends Stream<? extends R>, ? extends Exception> mapper) - Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
flattMapE
@Beta @ParallelSupported @IntermediateOp public <R> Stream<R> flattMapE(Throwables.Function<? super T, ? extends Collection<? extends R>, ? extends Exception> mapper) - Type Parameters:
R
-- Parameters:
mapper
-- Returns:
- See Also:
-
onEachE
@Beta @ParallelSupported @IntermediateOp public Stream<T> onEachE(Throwables.Consumer<? super T, ? extends Exception> action) - Type Parameters:
R
-- Parameters:
action
-- Returns:
- See Also:
-
mapToDisposableEntry
@Beta @SequentialOnly @Deprecated public <K,V> Stream<NoCachingNoUpdating.DisposableEntry<K,V>> mapToDisposableEntry(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) Deprecated.To reduce the memory footprint, Only one instance ofDisposableEntry
is created, and the same entry instance is returned and set with different keys/values during iteration of the returned stream. The elements only can be retrieved one by one, can't be modified or saved. The returned Stream doesn't support the operations which require two or more elements at the same time: (e.g. sort/distinct/pairMap/slidingMap/sliding/split/toList/toSet/...). , and can't be parallel stream. Operations: filter/map/toMap/groupBy/groupTo/... are supported.- Parameters:
keyMapper
-valueMapper
-- Returns:
- See Also:
-
asyncRun
@Beta @TerminalOp public ContinuableFuture<Void> asyncRun(Throwables.Consumer<? super Stream<T>, ? extends Exception> terminalAction) - Parameters:
terminalAction
- a terminal operation should be called.- Returns:
-
asyncRun
@Beta @TerminalOp public ContinuableFuture<Void> asyncRun(Throwables.Consumer<? super Stream<T>, ? extends Exception> terminalAction, Executor executor) - Parameters:
terminalAction
- a terminal operation should be called.executor
-- Returns:
-
asyncCall
@Beta @TerminalOp public <R> ContinuableFuture<R> asyncCall(Throwables.Function<? super Stream<T>, R, ? extends Exception> terminalAction) - Parameters:
terminalAction
- a terminal operation should be called.- Returns:
-
asyncCall
@Beta @TerminalOp public <R> ContinuableFuture<R> asyncCall(Throwables.Function<? super Stream<T>, R, ? extends Exception> terminalAction, Executor executor) - Parameters:
terminalAction
- a terminal operation should be called.executor
-- Returns:
-
empty
-
just
-
ofNullable
Returns an emptyStream
if the specifiedt
is null.- Type Parameters:
T
-- Parameters:
e
-- Returns:
-
of
-
of
- Parameters:
a
-startIndex
-endIndex
-- Returns:
-
of
- Parameters:
c
-- Returns:
-
of
- Parameters:
c
-startIndex
-endIndex
-- Returns:
-
of
-
of
-
of
- Parameters:
iterator
-- Returns:
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
ofKeys
-
ofKeys
-
ofKeys
public static <K,V> Stream<K> ofKeys(Map<? extends K, ? extends V> map, BiPredicate<? super K, ? super V> filter) -
ofValues
-
ofValues
-
ofValues
public static <K,V> Stream<V> ofValues(Map<? extends K, ? extends V> map, BiPredicate<? super K, ? super V> filter) -
from
Lazy evaluation.
This is equal to:Stream.just(supplier).flattMap(it -> it.get())
.- Parameters:
supplier
-- Returns:
-
defer
Lazy evaluation.
This is equal to:Stream.just(supplier).flatMap(it -> it.get())
.- Type Parameters:
T
-- Parameters:
supplier
-- Returns:
-
range
-
range
-
range
-
range
-
rangeClosed
-
rangeClosed
-
rangeClosed
-
rangeClosed
-
split
-
flatten
-
flatten
-
flatten
-
flatten
-
flatten
-
repeat
-
iterate
-
iterate
Returns a sequential orderedStream
produced by iterative application of a functionf
to an initial elementinit
, producing aStream
consisting ofinit
,f(init)
,f(f(init))
, etc.The first element (position
0
) in theStream
will be the providedinit
. Forn > 0
, the element at positionn
, will be the result of applying the functionf
to the element at positionn - 1
.- Parameters:
init
-hasNext
-f
-- Returns:
-
iterate
- Parameters:
init
-hasNext
- test if has next by hasNext.test(init) for first time and hasNext.test(f.apply(previous)) for remaining.f
-- Returns:
-
iterate
-
generate
-
interval
- Parameters:
intervalInMillis
-s
-- Returns:
-
interval
- Parameters:
delayInMillis
-intervalInMillis
-s
-- Returns:
- See Also:
-
interval
- Parameters:
delay
-interval
-unit
-s
-- Returns:
-
interval
-
interval
- Parameters:
delayInMillis
-intervalInMillis
-s
-- Returns:
- See Also:
-
interval
- Parameters:
delay
-interval
-unit
-s
-- Returns:
-
lines
- Throws:
UncheckedIOException
-
lines
- Throws:
UncheckedIOException
-
lines
- Throws:
UncheckedIOException
-
lines
- Throws:
UncheckedIOException
-
lines
It's user's responsibility to close the inputreader
after the stream is finished.- Parameters:
reader
-- Returns:
- Throws:
UncheckedIOException
-
listFiles
- Throws:
UncheckedIOException
-
listFiles
public static Stream<File> listFiles(File parentPath, boolean recursively) throws UncheckedIOException - Throws:
UncheckedIOException
-
observe
Sample code:final BlockingQueue
queue = new ArrayBlockingQueue<>(32); N.asyncExecute(() -> Stream.observe(queue, Duration.ofMillis(100)).filter(s -> s.startsWith("a")).forEach(Fn.println())); N.asList("a", "b", "ab", "bc", "1", "a").forEach(queue::add); N.sleep(10); N.println("=================="); N.sleep(100); N.println("=================="); N.sleep(10); - Parameters:
queue
-duration
-- Returns:
- See Also:
-
observe
@Beta public static <T> Stream<T> observe(BlockingQueue<T> queue, BooleanSupplier hasMore, long maxWaitIntervalInMillis) Sample code:final BlockingQueue
queue = new ArrayBlockingQueue<>(32); final MutableBoolean hasMore = MutableBoolean.of(true); N.asyncExecute(() -> Stream.observe(queue, () -> hasMore.value(), 10).filter(s -> s.startsWith("a")).forEach(Fn.println())); N.asList("a", "b", "ab", "bc", "1", "a").forEach(queue::add); N.println("=================="); hasMore.setFalse(); N.sleep(50); N.println("=================="); - Parameters:
queue
-hasMore
- it will will be set totrue
if Stream is completed and the upstream should not continue to put elements to queue when it's completed. This is an output parameter.maxWaitIntervalInMillis
-- Returns:
- See Also:
-
concat
-
concat
-
concat
-
concat
-
concat
-
concatIterables
-
concatIterators
-
parallelConcat
- Parameters:
a
-- Returns:
-
parallelConcat
public static <T> Stream<T> parallelConcat(Iterable<? extends T>[] a, int readThreadNum, int bufferSize) - Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, a.length)bufferSize
-- Returns:
-
parallelConcat
- Parameters:
a
-- Returns:
-
parallelConcat
public static <T> Stream<T> parallelConcat(Iterator<? extends T>[] a, int readThreadNum, int bufferSize) - Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, a.length)bufferSize
-- Returns:
-
parallelConcat
- Parameters:
a
-- Returns:
-
parallelConcat
public static <T> Stream<T> parallelConcat(Stream<? extends T>[] a, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.- Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, a.length)bufferSize
-- Returns:
-
parallelConcat
- Parameters:
c
-- Returns:
-
parallelConcat
public static <T> Stream<T> parallelConcat(Collection<? extends Stream<? extends T>> c, int readThreadNum) - Parameters:
c
-readThreadNum
-- Returns:
-
parallelConcat
public static <T> Stream<T> parallelConcat(Collection<? extends Stream<? extends T>> c, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.- Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, c.size())bufferSize
- Default value is N.min(128, c.size() * 16)- Returns:
-
parallelConcatIterables
@Beta public static <T> Stream<T> parallelConcatIterables(Collection<? extends Iterable<? extends T>> c) - Parameters:
c
-- Returns:
-
parallelConcatIterables
@Beta public static <T> Stream<T> parallelConcatIterables(Collection<? extends Iterable<? extends T>> c, int readThreadNum) - Parameters:
c
-readThreadNum
-- Returns:
-
parallelConcatIterables
@Beta public static <T> Stream<T> parallelConcatIterables(Collection<? extends Iterable<? extends T>> c, int readThreadNum, int bufferSize) Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterators in parallel.- Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, c.size())bufferSize
- Default value is N.min(128, c.size() * 16)- Returns:
-
parallelConcatIterators
- Parameters:
c
-- Returns:
-
parallelConcatIterators
public static <T> Stream<T> parallelConcatIterators(Collection<? extends Iterator<? extends T>> c, int readThreadNum) - Parameters:
c
-readThreadNum
-- Returns:
-
parallelConcatIterators
public static <T> Stream<T> parallelConcatIterators(Collection<? extends Iterator<? extends T>> c, int readThreadNum, int bufferSize) - Parameters:
a
-readThreadNum
- - count of threads used to read elements from iterator to queue. Default value is min(8, c.size())bufferSize
- Default value is N.min(128, c.size() * 16)- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(CharIterator a, CharIterator b, CharIterator c, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(CharStream a, CharStream b, CharStream c, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(char[] a, char[] b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(char[] a, char[] b, char[] c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(CharIterator a, CharIterator b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(CharIterator a, CharIterator b, CharIterator c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(CharStream a, CharStream b, char valueForNoneA, char valueForNoneB, CharBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(CharStream a, CharStream b, CharStream c, char valueForNoneA, char valueForNoneB, char valueForNoneC, CharTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends CharStream> c, char[] valuesForNone, CharNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteIterator a, ByteIterator b, ByteIterator c, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteStream a, ByteStream b, ByteStream c, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(byte[] a, byte[] b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(byte[] a, byte[] b, byte[] c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteIterator a, ByteIterator b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteIterator a, ByteIterator b, ByteIterator c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteStream a, ByteStream b, byte valueForNoneA, byte valueForNoneB, ByteBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ByteStream a, ByteStream b, ByteStream c, byte valueForNoneA, byte valueForNoneB, byte valueForNoneC, ByteTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends ByteStream> c, byte[] valuesForNone, ByteNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortIterator a, ShortIterator b, ShortIterator c, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortStream a, ShortStream b, ShortStream c, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(short[] a, short[] b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(short[] a, short[] b, short[] c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortIterator a, ShortIterator b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortIterator a, ShortIterator b, ShortIterator c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortStream a, ShortStream b, short valueForNoneA, short valueForNoneB, ShortBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(ShortStream a, ShortStream b, ShortStream c, short valueForNoneA, short valueForNoneB, short valueForNoneC, ShortTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends ShortStream> c, short[] valuesForNone, ShortNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(IntIterator a, IntIterator b, IntIterator c, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(IntStream a, IntStream b, IntStream c, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(int[] a, int[] b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(int[] a, int[] b, int[] c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(IntIterator a, IntIterator b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(IntIterator a, IntIterator b, IntIterator c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(IntStream a, IntStream b, int valueForNoneA, int valueForNoneB, IntBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(IntStream a, IntStream b, IntStream c, int valueForNoneA, int valueForNoneB, int valueForNoneC, IntTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends IntStream> c, int[] valuesForNone, IntNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(LongIterator a, LongIterator b, LongIterator c, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(LongStream a, LongStream b, LongStream c, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(long[] a, long[] b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(long[] a, long[] b, long[] c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(LongIterator a, LongIterator b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(LongIterator a, LongIterator b, LongIterator c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(LongStream a, LongStream b, long valueForNoneA, long valueForNoneB, LongBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(LongStream a, LongStream b, LongStream c, long valueForNoneA, long valueForNoneB, long valueForNoneC, LongTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends LongStream> c, long[] valuesForNone, LongNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatIterator a, FloatIterator b, FloatIterator c, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatStream a, FloatStream b, FloatStream c, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(float[] a, float[] b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(float[] a, float[] b, float[] c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatIterator a, FloatIterator b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatIterator a, FloatIterator b, FloatIterator c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatStream a, FloatStream b, float valueForNoneA, float valueForNoneB, FloatBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(FloatStream a, FloatStream b, FloatStream c, float valueForNoneA, float valueForNoneB, float valueForNoneC, FloatTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends FloatStream> c, float[] valuesForNone, FloatNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(double[] a, double[] b, double[] c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleIterator a, DoubleIterator b, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleIterator a, DoubleIterator b, DoubleIterator c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleStream a, DoubleStream b, DoubleStream c, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends DoubleStream> c, DoubleNFunction<R> zipFunction) Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(double[] a, double[] b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(double[] a, double[] b, double[] c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleIterator a, DoubleIterator b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleIterator a, DoubleIterator b, DoubleIterator c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleStream a, DoubleStream b, double valueForNoneA, double valueForNoneB, DoubleBiFunction<R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(DoubleStream a, DoubleStream b, DoubleStream c, double valueForNoneA, double valueForNoneB, double valueForNoneC, DoubleTriFunction<R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <R> Stream<R> zip(Collection<? extends DoubleStream> c, double[] valuesForNone, DoubleNFunction<R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zip
Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (A[] a, B[] b, C[] c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" arrays until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" arrays until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Stream<? extends A> a, Stream<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" streams until one of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Stream<? extends A> a, Stream<? extends B> b, Stream<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" streams until one of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-- Returns:
-
zip
public static <T,R> Stream<R> zip(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction) Zip together the iterators until one of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-zipFunction
-- Returns:
-
zipIterables
public static <T,R> Stream<R> zipIterables(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction) -
zipIterators
public static <T,R> Stream<R> zipIterators(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction) -
zip
public static <A,B, Stream<R> zipR> (A[] a, B[] b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (A[] a, B[] b, C[] c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipR> (Stream<? extends A> a, Stream<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) Zip together the "a" and "b" iterators until all of them runs out of values. Each pair of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-valueForNoneA
- value to fill if "a" runs out of values first.valueForNoneB
- value to fill if "b" runs out of values first.zipFunction
-- Returns:
-
zip
public static <A,B, Stream<R> zipC, R> (Stream<? extends A> a, Stream<? extends B> b, Stream<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) Zip together the "a", "b" and "c" iterators until all of them runs out of values. Each triple of values is combined into a single value using the supplied zipFunction function.- Parameters:
a
-b
-c
-valueForNoneA
- value to fill if "a" runs out of values.valueForNoneB
- value to fill if "b" runs out of values.valueForNoneC
- value to fill if "c" runs out of values.zipFunction
-- Returns:
-
zip
public static <T,R> Stream<R> zip(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) Zip together the iterators until all of them runs out of values. Each array of values is combined into a single value using the supplied zipFunction function.- Parameters:
c
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
zipIterables
public static <T,R> Stream<R> zipIterables(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) - Type Parameters:
T
-R
-- Parameters:
collections
-valuesForNone
-zipFunction
-- Returns:
-
zipIterators
public static <T,R> Stream<R> zipIterators(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) - Parameters:
iterators
-valuesForNone
- value to fill for any iterator runs out of values.zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterable<? extends A> a, Iterable<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
A
-B
-C
-R
-- Parameters:
a
-b
-c
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterator<? extends A> a, Iterator<? extends B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
A
-B
-C
-R
-- Parameters:
a
-b
-c
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Stream<A> a, Stream<B> b, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Stream<A> a, Stream<B> b, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Stream<A> a, Stream<B> b, Stream<C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
A
-B
-C
-R
-- Parameters:
a
-b
-c
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Stream<A> a, Stream<B> b, Stream<C> c, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <T,R> Stream<R> parallelZip(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
c
-zipFunction
-- Returns:
-
parallelZip
public static <T,R> Stream<R> parallelZip(Collection<? extends Stream<? extends T>> c, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterable<? extends A> a, Iterable<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterable<? extends A> a, Iterable<? extends B> b, Iterable<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Iterator<? extends A> a, Iterator<? extends B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Iterator<? extends A> a, Iterator<? extends B> b, Iterator<? extends C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Stream<A> a, Stream<B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipR> (Stream<A> a, Stream<B> b, A valueForNoneA, B valueForNoneB, BiFunction<? super A, ? super B, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-valueForNoneA
-valueForNoneB
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Stream<A> a, Stream<B> b, Stream<C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-- Returns:
-
parallelZip
public static <A,B, Stream<R> parallelZipC, R> (Stream<A> a, Stream<B> b, Stream<C> c, A valueForNoneA, B valueForNoneB, C valueForNoneC, TriFunction<? super A, ? super B, ? super C, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-c
-valueForNoneA
-valueForNoneB
-valueForNoneC
-zipFunction
-bufferSize
-- Returns:
-
parallelZip
public static <T,R> Stream<R> parallelZip(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
c
-valuesForNone
-zipFunction
-- Returns:
-
parallelZip
public static <T,R> Stream<R> parallelZip(Collection<? extends Stream<? extends T>> c, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
c
-valuesForNone
-zipFunction
-bufferSize
-- Returns:
-
parallelZipIterables
@Beta public static <T,R> Stream<R> parallelZipIterables(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
T
-R
-- Parameters:
collections
-zipFunction
-- Returns:
-
parallelZipIterables
@Beta public static <T,R> Stream<R> parallelZipIterables(Collection<? extends Iterable<? extends T>> collections, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
T
-R
-- Parameters:
collections
-zipFunction
-bufferSize
-- Returns:
-
parallelZipIterables
@Beta public static <T,R> Stream<R> parallelZipIterables(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
T
-R
-- Parameters:
collections
-valuesForNone
-zipFunction
-- Returns:
-
parallelZipIterables
@Beta public static <T,R> Stream<R> parallelZipIterables(Collection<? extends Iterable<? extends T>> collections, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Type Parameters:
T
-R
-- Parameters:
collections
-valuesForNone
-zipFunction
-bufferSize
-- Returns:
-
parallelZipIterators
public static <T,R> Stream<R> parallelZipIterators(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
iterators
-zipFunction
-- Returns:
-
parallelZipIterators
public static <T,R> Stream<R> parallelZipIterators(Collection<? extends Iterator<? extends T>> iterators, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
a
-b
-iterators
-zipFunction
-bufferSize
-- Returns:
-
parallelZipIterators
public static <T,R> Stream<R> parallelZipIterators(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
iterators
-valuesForNone
-zipFunction
-- Returns:
-
parallelZipIterators
public static <T,R> Stream<R> parallelZipIterators(Collection<? extends Iterator<? extends T>> iterators, List<? extends T> valuesForNone, Function<? super List<? extends T>, R> zipFunction, int bufferSize) A new thread will be started for eachIterator/Collection/Stream
to read the elements to queue for thezipFunction
. But thezipFunction
will be executed in a single thread, not multiple threads. To parallelize thezipFunction
, callStream.parallelZip(..., Pair::of/Triple::of/Fn.identity()).parallel().map(zipFunction)...
- Parameters:
iterators
-valuesForNone
-zipFunction
-bufferSize
-- Returns:
-
merge
public static <T> Stream<T> merge(T[] a, T[] b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(T[] a, T[] b, T[] c, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Iterable<? extends T> a, Iterable<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Iterable<? extends T> a, Iterable<? extends T> b, Iterable<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Iterator<? extends T> a, Iterator<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Iterator<? extends T> a, Iterator<? extends T> b, Iterator<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Stream<? extends T> a, Stream<? extends T> b, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
a
-b
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
merge
public static <T> Stream<T> merge(Stream<? extends T> a, Stream<? extends T> b, Stream<? extends T> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) -
merge
public static <T> Stream<T> merge(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Parameters:
c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
mergeIterables
public static <T> Stream<T> mergeIterables(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Type Parameters:
T
-- Parameters:
collections
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
mergeIterators
public static <T> Stream<T> mergeIterators(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector) - Type Parameters:
T
-- Parameters:
iterators
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
parallelMerge
public static <T> Stream<T> parallelMerge(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Parameters:
c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
parallelMerge
public static <T> Stream<T> parallelMerge(Collection<? extends Stream<? extends T>> c, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Parameters:
c
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.maxThreadNum
-- Returns:
-
parallelMergeIterables
public static <T> Stream<T> parallelMergeIterables(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Type Parameters:
T
-- Parameters:
collections
-nextSelector
-- Returns:
-
parallelMergeIterables
public static <T> Stream<T> parallelMergeIterables(Collection<? extends Iterable<? extends T>> collections, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Type Parameters:
T
-- Parameters:
collections
-nextSelector
-maxThreadNum
-- Returns:
-
parallelMergeIterators
public static <T> Stream<T> parallelMergeIterators(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Parameters:
iterators
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.- Returns:
-
parallelMergeIterators
public static <T> Stream<T> parallelMergeIterators(Collection<? extends Iterator<? extends T>> iterators, BiFunction<? super T, ? super T, MergeResult> nextSelector, int maxThreadNum) All the elements from each inputCollection/Iterator/Stream
will be merged into two queues by multiple threads. Then these two new queues will be merged into oneIterator/Stream
by one thread. So it's not totally lazy evaluation and may cause out of memory error if there are too many elements merged into the new queues. Consider usingmerge
, which is totally lazy evaluation.- Parameters:
iterators
-nextSelector
- first parameter is selected ifNth.FIRST
is returned, otherwise the second parameter is selected.maxThreadNum
-- Returns:
-
elementAt
- Specified by:
elementAt
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Parameters:
position
- in current stream(not upstream or origin source). It starts from 0.- Returns:
-
rateLimited
- Specified by:
rateLimited
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
peek
- Specified by:
peek
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
sliding
- Specified by:
sliding
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
slidingToList
- Specified by:
slidingToList
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
shuffled
Description copied from interface:BaseStream
This method only runs sequentially, even in parallel stream and all elements will be loaded to memory.- Specified by:
shuffled
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
-
throwIfEmpty
@SequentialOnly @IntermediateOp public Stream<T> throwIfEmpty(Supplier<? extends RuntimeException> exceptionSupplier) - Specified by:
throwIfEmpty
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
toImmutableList
- Specified by:
toImmutableList
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
toImmutableSet
- Specified by:
toImmutableSet
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
join
- Specified by:
join
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
println
public void println()- Specified by:
println
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
__
- Specified by:
__
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
isParallel
public boolean isParallel()- Specified by:
isParallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
sequential
- Specified by:
sequential
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
parallel
Description copied from interface:BaseStream
Consider usingsps(Function)
if only next operation need to be parallelized. For example:stream.parallel().map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel().map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Consider usingsps(int, Function)
if only next operation need to be parallelized. For example:stream.parallel(maxThreadNum).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(maxThreadNum, s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(maxThreadNum).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(int, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(splitor).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(splitor), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(splitor).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Returns an equivalent stream that is parallel. May return itself if the stream was already parallel with the samemaxThreadNum
andsplitor
as the specified ones.
When to use parallel Streams?- First of all, do NOT and should NOT use parallel Streams if you don't have any problem with sequential Streams, because using parallel Streams has extra cost.
- Consider using parallel Streams only when N(the number of elements) * Q(cost per element of F, the per-element function (usually a lambda)) is big enough(e.g. IO involved. Network: DB/web service request..., Reading/Writing file...).
- It's easy to test out the differences of performance by sequential Streams and parallel Streams with Profiler:
Profiler.run(1, 1, 3, "sequential", () -> Stream.of(list).operation(F)...).printResult(); Profiler.run(1, 1, 3, "parallel", () -> Stream.of(list).parallel().operation(F)...).printResult();
public void test_perf() { final String[] strs = new String[10_000]; N.fill(strs, N.uuid()); final int m = 10; final Function<String, Long> mapper = str -> { long result = 0; for (int i = 0; i < m; i++) { result += N.sum(str.toCharArray()) + 1; } return result; }; final MutableLong sum = MutableLong.of(0); for (int i = 0, len = strs.length; i < len; i++) { sum.add(mapper.apply(strs[i])); } final int threadNum = 1, loopNum = 100, roundNum = 3; Profiler.run(threadNum, loopNum, roundNum, "For Loop", () -> { long result = 0; for (int i = 0, len = strs.length; i < len; i++) { result += mapper.apply(strs[i]); } assertEquals(sum.longValue(), result); }).printResult(); Profiler.run(threadNum, loopNum, roundNum, "JDK Sequential", () -> assertEquals(sum.longValue(), java.util.stream.Stream.of(strs).map(mapper).mapToLong(e -> e).sum())).printResult(); Profiler.run(threadNum, loopNum, roundNum, "JDK Parallel", () -> assertEquals(sum.longValue(), java.util.stream.Stream.of(strs).parallel().map(mapper).mapToLong(e -> e).sum())).printResult(); Profiler.run(threadNum, loopNum, roundNum, "Abcus Sequential", () -> assertEquals(sum.longValue(), Stream.of(strs).map(mapper).mapToLong(e -> e).sum())) .printResult(); Profiler.run(threadNum, loopNum, roundNum, "Abcus Parallel", () -> assertEquals(sum.longValue(), Stream.of(strs).parallel().map(mapper).mapToLong(e -> e).sum())).printResult(); Profiler.run(threadNum, loopNum, roundNum, "Abcus Parallel by chunck", () -> assertEquals(sum.longValue(), Stream.of(strs).splitToList(100).parallel().map(it -> N.sumLong(it, e -> mapper.apply(e))).mapToLong(e -> e).sum())).printResult(); }
mapper
) is calculated by: value of 'For loop' / N(10_000).m = 1 m = 10 m = 50 m = 100 m = 500 m = 1000 Q 0.00002 0.0002 0.001 0.002 0.01 0.02 For Loop 0.23 2.3 11 22 110 219 JDK Sequential 0.28 2.3 11 22 114 212 JDK Parallel 0.22 1.3 6 12 66 122 Abcus Sequential 0.3 2 11 22 112 212 Abcus Parallel 11 11 11 16 77 128 - Again, do NOT and should NOT use parallel Streams if you don't have any performance problem with sequential Streams, because using parallel Streams has extra cost.
- Again, consider using parallel Streams only when N(the number of elements) * Q(cost per element of F, the per-element function (usually a lambda)) is big enough.
- The implementation of parallel Streams in Abacus is more than 10 times, slower than parallel Streams in JDK when Q is tiny(here is less than 0.0002 milliseconds by the test):
- The implementation of parallel Streams in JDK 8 still can beat the sequential/for loop when Q is tiny(Here is 0.00002 milliseconds by the test). That's amazing, considering the extra cost brought by parallel computation. It's well done.
- The implementation of parallel Streams in Abacus is pretty simple and straight forward. The extra cost(starting threads/synchronization/queue...) brought by parallel Streams in Abacus is too bigger to tiny Q(Here is less than 0.001 milliseconds by the test). But it starts to be faster than sequential Streams when Q is big enough(Here is 0.001 milliseconds by the test) and starts to catch the parallel Streams in JDK when Q is bigger(Here is 0.01 milliseconds by the test).
- Consider using the parallel Streams in Abacus when Q is big enough, specially when IO involved in F. Because one IO operation(e.g. DB/web service request..., Reading/Writing file...) usually takes 1 to 1000 milliseconds, or even longer. By the parallel Streams APIs in Abacus, it's very simple to specify max thread numbers. Sometimes, it's much faster to execute IO/Network requests with a bit more threads. It's fair to say that the parallel Streams in Abacus is high efficient, may same as or faster than the parallel Streams in JDK when Q is big enough, except F is heavy cpu-used operation. Most of the times, the Q is big enough to consider using parallel Stream is because IO/Network is involved in F.
- JDK 7 is supported by the Streams in Abacus. It's perfect to work with retrolambda on Android
- All primitive types are supported by Stream APIs in Abacus except boolean
A bit more about Lambdas/Stream APIs, you may heard that Lambdas/Stream APIs is 5 time slower than imperative programming. It's true when Q and F is VERY, VERY tiny, likef = (int a, int b) -> a + b;
. But if we look into the samples in the article and think about it: it just takes less than 1 milliseconds to get the max value in 100k numbers. There is potential performance issue only if the "get the max value in 100K numbers" call many, many times in your API or single request. Otherwise, the difference between 0.1 milliseconds to 0.5 milliseconds can be totally ignored. Usually we meet performance issue only if Q and F is big enough. However, the performance of Lambdas/Streams APIs is closed to for loop when Q and F is big enough. No matter in which scenario, We don't need and should not concern the performance of Lambdas/Stream APIs.
Although it's is parallel Streams, it doesn't means all the methods are executed in parallel. Because the sequential way is as fast, or even faster than the parallel way for some methods, or is pretty difficult, if not possible, to implement the method by parallel approach. Here are the methods which are executed sequentially even in parallel Streams.
splitXXX/splitAt/splitBy/slidingXXX/collapse, distinct, reverse, rotate, shuffle, indexed, cached, top, kthLargest, count, toArray, toList, toList, toSet, toMultiset, toLongMultiset, intersection(Collection c), difference(Collection c), symmetricDifference(Collection c), forEach(identity, accumulator, predicate), findFirstOrLast, findFirstAndLast- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Parameters:
maxThreadNum
- Default value is the number of cpu-cores. Steps/operations will be executed sequentially ifmaxThreadNum
is 1.splitor
- The target array is split by ranges for multiple threads if splitor issplitor.ARRAY
and target stream composed by array. It looks like:
Otherwise, each thread will get the elements from the target array/iterator in the stream one by one with the target array/iterator synchronized. It looks like:for (int i = 0; i < maxThreadNum; i++) { final int sliceIndex = i; futureList.add(asyncExecutor.execute(new Runnable() { public void run() { int cursor = fromIndex + sliceIndex * sliceSize; final int to = toIndex - cursor > sliceSize ? cursor + sliceSize : toIndex; while (cursor < to) { action.accept(elements[cursor++]); } } })); }
Usingfor (int i = 0; i < maxThreadNum; i++) { futureList.add(asyncExecutor.execute(new Runnable() { public void run() { T next = null; while (true) { synchronized (elements) { if (cursor.intValue() < toIndex) { next = elements[cursor.getAndIncrement()]; } else { break; } } action.accept(next); } } })); }
splitor.ARRAY
only when F (the per-element function (usually a lambda)) is very tiny and the cost of synchronization on the target array/iterator is too big to it. For the F involving IO or taking 'long' to complete, choosesplitor.ITERATOR
. Default value issplitor.ITERATOR
.
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(maxThreadNum, splitor).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(maxThreadNum, splitor), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(maxThreadNum, splitor).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Returns:
- See Also:
-
BaseStream.parallel(Executor)
BaseStream.parallel(int, Executor)
BaseStream.parallel(int, Splitor, Executor)
BaseStream.sps(Function)
BaseStream.sps(int, Function)
BaseStream.sps(ParallelSettings, Function)
MergeResult
com.landawn.abacus.util.Profiler#run(int, int, int, String, Runnable)
- Understanding Parallel Stream Performance in Java SE 8
- When to use parallel Streams
-
parallel
Description copied from interface:BaseStream
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(maxThreadNum, executor).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(maxThreadNum, executor), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(maxThreadNum, executor).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> executor
- should be able to executemaxThreadNum
*following up operations
in parallel.- Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(executor).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(executor), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(executor).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Parameters:
executor
- should be able to executemaxThreadNum
*following up operations
in parallel.- Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(maxThreadNum, splitor, executor).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(maxThreadNum, splitor, executor), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(maxThreadNum, splitor, executor).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> executor
- should be able to executemaxThreadNum
*following up operations
in parallel.- Returns:
- See Also:
-
parallel
Description copied from interface:BaseStream
Consider usingsps(ParallelSettings, Function)
if only next operation need to be parallelized. For example:stream.parallel(parallelSettings).map(f).filter(p)...; // Replace above line of code with "sps" if only "f" need to be parallelized. And "p" is fast enough to be executed in sequential Stream. stream.sps(SP.create(parallelSettings), s -> s.map(f)).filter(p)...; // Or switch the stream back sequential stream if don't use "sps". stream.parallel(parallelSettings).map(f).sequential().filter(p)...;
In most scenarios, there could be only one operation need be parallelized in the stream. Sosps(ParallelSettings, Function)
is recommended in most of scenarios.- Specified by:
parallel
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
- See Also:
-
sps
Description copied from interface:BaseStream
Temporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.
stream().parallel().ops(map/filter/...).sequence()
- Specified by:
sps
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
-
sps
public <SS extends BaseStream> SS sps(int maxThreadNum, Function<? super Stream<T>, ? extends SS> ops) Description copied from interface:BaseStream
Temporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.
stream().parallel(maxThreadNum).ops(map/filter/...).sequence()
- Specified by:
sps
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
-
sps
public <SS extends BaseStream> SS sps(BaseStream.ParallelSettings ps, Function<? super Stream<T>, ? extends SS> ops) Description copied from interface:BaseStream
Temporarily switch the stream to parallel stream for operationops
and then switch back to sequence stream.
stream().parallel(ps).ops(map/filter/...).sequence()
- Specified by:
sps
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
-
psp
Description copied from interface:BaseStream
Temporarily switch the stream to sequence stream for operationops
and then switch back to parallel stream with samemaxThreadNum/splitor/asyncExecutor
.
stream().sequence().ops(map/filter/...).parallel(sameMaxThreadNum, sameSplitor, sameAsyncExecutor)
- Specified by:
psp
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Returns:
-
toArray
- Specified by:
toArray
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>>
-
close
public void close()Description copied from interface:BaseStream
It will be called by terminal operations in final.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceBaseStream<T,
A, P, C, PL, OT, IT, ITER extends Iterator<T>, S extends com.landawn.abacus.util.stream.StreamBase<T, A, P, C, PL, OT, IT, ITER, S>> - Specified by:
close
in interfaceCloseable
-
mergeWith(Stream, BiFunction)