diff --git a/kool/src/main/java/org/davidmoten/kool/Stream.java b/kool/src/main/java/org/davidmoten/kool/Stream.java index 1d9446d..b270ce8 100644 --- a/kool/src/main/java/org/davidmoten/kool/Stream.java +++ b/kool/src/main/java/org/davidmoten/kool/Stream.java @@ -952,6 +952,22 @@ default Stream bufferUntil(Callable factory, step, maxReplay); } + /** + * Buffers while 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 bufferWhile(Callable factory, BiFunction accumulator, BiPredicate condition, boolean emitRemainder, Function step, int maxReplay) {