Class StreamUtil


  • public class StreamUtil
    extends Object
    Author:
    Herbert Praehofer
    • Constructor Detail

      • StreamUtil

        public StreamUtil()
    • Method Detail

      • number

        public static <A extends Comparable<A>> Stream<Numbered<A>> number​(Stream<A> as)
        Creates a stream of numbered values from a stream of values.
        Type Parameters:
        A - type of the value
        Parameters:
        as - the stream of values
        Returns:
        the stream of the numbered values
      • zip

        public static <A,​B> Stream<Pair<A,​B>> zip​(Stream<A> as,
                                                              Stream<B> bs)
        Creates a stream of pairs of values from two streams.
        Type Parameters:
        A - the type of values of the first stream
        B - the type of values of the second stream
        Parameters:
        as - the first stream
        bs - the second stream
        Returns:
        the stream of pairs of values from the two streams
      • number2

        public static <A> Stream<Pair<Integer,​A>> number2​(Stream<A> as)
        Creates a stream of numbered values from a stream of values. Is an alternative implementation of number(Stream) using zip(Stream, Stream).
        Type Parameters:
        A - type of the value
        Parameters:
        as - the stream of values
        Returns:
        the stream of the numbered values