diff --git a/kool/src/main/java/org/davidmoten/kool/Stream.java b/kool/src/main/java/org/davidmoten/kool/Stream.java index d5f2115..feb7e3e 100644 --- a/kool/src/main/java/org/davidmoten/kool/Stream.java +++ b/kool/src/main/java/org/davidmoten/kool/Stream.java @@ -945,6 +945,22 @@ default Stream> bufferWhile(BiPredicate, ? super T> cond return bufferWhile(ArrayList::new, StreamUtils.listAccumulator(), condition, emitRemainder, step, maxReplay); } + /** + * Buffers until a condition is true then emits the buffer and starts a new + * buffer for emission. + * + * @param buffer type + * @param factory factory method to create a new buffer + * @param accumulator how to incorporate a stream element into the buffer + * @param condition if true then stream element is incorporated into the + * buffer + * @param emitRemainder what to do with the final buffer + * @param step function that defines overlap (or not) of buffers + * @param maxReplay overlap of buffers is achieved efficiently via a ring + * buffer (the stream is made replayable to handle buffer + * overlaps (e.g step = 1) + * @return buffered stream + */ default Stream bufferUntil(Callable factory, BiFunction accumulator, BiPredicate condition, boolean emitRemainder, Function step, int maxReplay) {