diff --git a/src/main/java/net/kemitix/text/fit/StreamZipper.java b/src/main/java/net/kemitix/text/fit/StreamZipper.java new file mode 100644 index 0000000..4fe001a --- /dev/null +++ b/src/main/java/net/kemitix/text/fit/StreamZipper.java @@ -0,0 +1,60 @@ +package net.kemitix.text.fit; + + +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.IntFunction; +import java.util.stream.Stream; + +import static java.lang.Math.min; +import static java.util.stream.IntStream.range; + +/** + * Utility to zip two {@link Stream}s together. + * + * @author Paul Campbell (pcampbell@kemitix.net) + */ +public final class StreamZipper { + + private StreamZipper() { + throw new UnsupportedOperationException(); + } + + /** + * Zip two {@link Stream}s together. + * + *
The resulting stream will contain only as many items as the shortest of the two lists.
+ * + * @param a the first List + * @param b the second List + * @param zipper the function to zip an item from each list + * @param the type of the first list + * @param the type of the second list + * @param