Package rsp.util

Class StreamUtils


  • public final class StreamUtils
    extends Object
    • Constructor Detail

      • StreamUtils

        public StreamUtils()
    • 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.