Skip to content

Commit

Permalink
add bufferWhile/bufferUntil builder accumulator convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmoten committed Dec 3, 2024
1 parent 5e0cb6c commit 63b65ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kool/src/main/java/org/davidmoten/kool/BufferBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.concurrent.Callable;

import org.davidmoten.kool.function.BiConsumer;
import org.davidmoten.kool.function.BiFunction;
import org.davidmoten.kool.function.BiPredicate;
import org.davidmoten.kool.function.Function;
Expand Down Expand Up @@ -93,6 +94,11 @@ public BuilderHasAccumulator<T, S> accumulator(BiFunction<? super S, ? super T,
b.accumulator = accumulator;
return new BuilderHasAccumulator<T, S>(b);
}

public BuilderHasAccumulator<T, S> accumulator(BiConsumer<? super S, ? super T> accumulator) {
b.accumulator = (buffer, t) -> {accumulator.accept(buffer, t); return buffer;};
return new BuilderHasAccumulator<T, S>(b);
}
}

public static final class BuilderHasAccumulator<T, S> {
Expand Down

0 comments on commit 63b65ef

Please sign in to comment.