mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8071597: Add Stream dropWhile and takeWhile operations
Reviewed-by: briangoetz, smarks, chegar, forax
This commit is contained in:
parent
5d91ae3352
commit
5744f4fc30
18 changed files with 3665 additions and 41 deletions
|
@ -122,8 +122,10 @@ abstract class ReferencePipeline<P_IN, P_OUT>
|
|||
}
|
||||
|
||||
@Override
|
||||
final void forEachWithCancel(Spliterator<P_OUT> spliterator, Sink<P_OUT> sink) {
|
||||
do { } while (!sink.cancellationRequested() && spliterator.tryAdvance(sink));
|
||||
final boolean forEachWithCancel(Spliterator<P_OUT> spliterator, Sink<P_OUT> sink) {
|
||||
boolean cancelled;
|
||||
do { } while (!(cancelled = sink.cancellationRequested()) && spliterator.tryAdvance(sink));
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -411,6 +413,16 @@ abstract class ReferencePipeline<P_IN, P_OUT>
|
|||
return SliceOps.makeRef(this, n, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<P_OUT> takeWhile(Predicate<? super P_OUT> predicate) {
|
||||
return WhileOps.makeTakeWhileRef(this, predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<P_OUT> dropWhile(Predicate<? super P_OUT> predicate) {
|
||||
return WhileOps.makeDropWhileRef(this, predicate);
|
||||
}
|
||||
|
||||
// Terminal operations from Stream
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue