Package rsp.util
Class StreamUtils
- java.lang.Object
-
- rsp.util.StreamUtils
-
public final class StreamUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description StreamUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Stream<T>iterate(Iterator<? extends T> iterator)static <T,R>
Stream<R>mapWithIndex(Stream<? extends T> stream, BiFunction<Integer,? super T,? extends R> mapper)Returns a stream consisting of the results of applying the given two-arguments function to the elements of this stream.static <T> CompletableFuture<List<T>>sequence(List<CompletableFuture<T>> listOfCompletableFutures)Converts a list of CompletableFuture to a CompletableFuture of a liststatic <L,R,T>
Stream<T>zip(Stream<L> leftStream, Stream<R> rightStream, BiFunction<L,R,T> combiner)Zips two streams.static <T> Stream<Map.Entry<Integer,T>>zipWithIndex(Stream<? extends T> stream)Zips the specified stream with its indices.
-
-
-
Method Detail
-
zip
public static <L,R,T> Stream<T> zip(Stream<L> leftStream, Stream<R> rightStream, BiFunction<L,R,T> combiner)
Zips two streams. The resulting stream is truncated to the shorter of the two input streams.
-
zipWithIndex
public static <T> Stream<Map.Entry<Integer,T>> zipWithIndex(Stream<? extends T> stream)
Zips the specified stream with its indices.
-
mapWithIndex
public static <T,R> Stream<R> mapWithIndex(Stream<? extends T> stream, BiFunction<Integer,? super T,? extends R> mapper)
Returns a stream consisting of the results of applying the given two-arguments function to the elements of this stream. The first argument of the function is the element index and the second one - the element value.
-
sequence
public static <T> CompletableFuture<List<T>> sequence(List<CompletableFuture<T>> listOfCompletableFutures)
Converts a list of CompletableFuture to a CompletableFuture of a list
-
-