RFR 8071597 Add Stream dropWhile and takeWhile operations
Paul Sandoz
paul.sandoz at oracle.com
Thu Jun 4 07:37:58 UTC 2015
On Jun 4, 2015, at 9:04 AM, Remi Forax <forax at univ-mlv.fr> wrote:
> Thinking a little more about dropWhile(),
> it can be written using filter() more or less like this:
> default Stream<T> dropWhile(Predicate<? super T> predicate) {
> return filter(new Predicate<>() {
> private boolean noDropAnymore;
> public boolean test(T t) {
> return noDropAnymore || (noDropAnymore = !predicate.test(t));
> }
> });
> }
> and i maybe wrong but implementing dropWhile with an op is not better than that in term of perf so for me dropWhile() doesn't pull its own weight.
>
Try running that in parallel.
(Stream.parallel() affects the whole pipeline, so it's not possible to implement the default with sequential().filter(p) where p is a stateful predicate.)
Paul.
More information about the core-libs-dev
mailing list