Package at.jku.ssw.fp.sect07_7
Class StreamUtil
- java.lang.Object
-
- at.jku.ssw.fp.sect07_7.StreamUtil
-
public class StreamUtil extends Object
- Author:
- Herbert Praehofer
-
-
Constructor Summary
Constructors Constructor Description StreamUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <A extends Comparable<A>>
Stream<Numbered<A>>number(Stream<A> as)
Creates a stream of numbered values from a stream of values.static <A> Stream<Pair<Integer,A>>
number2(Stream<A> as)
Creates a stream of numbered values from a stream of values.static <A,B>
Stream<Pair<A,B>>zip(Stream<A> as, Stream<B> bs)
Creates a stream of pairs of values from two streams.
-
-
-
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 streamB
- the type of values of the second stream- Parameters:
as
- the first streambs
- 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 ofnumber(Stream)
usingzip(Stream, Stream)
.- Type Parameters:
A
- type of the value- Parameters:
as
- the stream of values- Returns:
- the stream of the numbered values
-
-