public final class StreamUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.util.stream.LongStream |
indices()
Constructs an infinite (although in practice bounded by Long.MAX_VALUE) stream of longs 0, 1, 2, 3...
|
static <T> java.util.stream.Stream<T> |
skipUntil(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
Construct a stream which skips values from the source stream for as long as they do not meet the supplied condition,
then streams every remaining value as soon as the first value is found which does meet the condition.
|
static <T> java.util.stream.Stream<T> |
skipWhile(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
Construct a stream which skips values from the source stream for as long as they meet the supplied condition,
then streams every remaining value as soon as the first value is found which does not meet the condition.
|
static <T> java.util.stream.Stream<T> |
takeUntil(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
Construct a stream which takes values from the source stream until one of them meets the supplied condition,
and then stops.
|
static <T> java.util.stream.Stream<T> |
takeWhile(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
Construct a stream which takes values from the source stream for as long as they meet the supplied condition, and stops
as soon as a value is encountered which does not meet the condition.
|
static <T> java.util.stream.Stream<T> |
unfold(T seed,
java.util.function.Function<T,java.util.Optional<T>> generator)
Construct a stream which takes the seed value and applies the generator to create the next value, feeding each
new value back into the generator to create subsequent values.
|
static <L,R,O> java.util.stream.Stream<O> |
zip(java.util.stream.Stream<L> lefts,
java.util.stream.Stream<R> rights,
java.util.function.BiFunction<L,R,O> combiner)
Zip together the "left" and "right" streams until either runs out of values.
|
static <T> java.util.stream.Stream<Indexed<T>> |
zipWithIndex(java.util.stream.Stream<T> source)
Zip the source stream together with the stream of indices() to provide a stream of indexed values.
|
public static java.util.stream.LongStream indices()
public static <T> java.util.stream.Stream<Indexed<T>> zipWithIndex(java.util.stream.Stream<T> source)
T - The type over which the source stream streams.source - The source stream.public static <L,R,O> java.util.stream.Stream<O> zip(java.util.stream.Stream<L> lefts,
java.util.stream.Stream<R> rights,
java.util.function.BiFunction<L,R,O> combiner)
L - The type over which the "left" stream streams.R - The type over which the "right" stream streams.O - The type created by the combiner out of pairs of "left" and "right" values, over which the resulting
stream streams.lefts - The "left" stream to zip.rights - The "right" stream to zip.combiner - The function to combine "left" and "right" values.public static <T> java.util.stream.Stream<T> takeWhile(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
T - The type over which the stream streams.source - The source stream.condition - The condition to apply to elements of the source stream.public static <T> java.util.stream.Stream<T> takeUntil(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
T - The type over which the stream streams.source - The source stream.condition - The condition to apply to elements of the source stream.public static <T> java.util.stream.Stream<T> skipWhile(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
T - The type over which the stream streams.source - The source stream.condition - The condition to apply to elements of the source stream.public static <T> java.util.stream.Stream<T> skipUntil(java.util.stream.Stream<T> source,
java.util.function.Predicate<T> condition)
T - The type over which the stream streams.source - The source stream.condition - The condition to apply to elements of the source stream.public static <T> java.util.stream.Stream<T> unfold(T seed,
java.util.function.Function<T,java.util.Optional<T>> generator)
T - The type over which the stream streams.seed - The seed value.generator - The generator to use to create new values.Copyright © 2014. All Rights Reserved.