mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +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
|
@ -156,10 +156,12 @@ abstract class IntPipeline<E_IN>
|
|||
}
|
||||
|
||||
@Override
|
||||
final void forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
|
||||
final boolean forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
|
||||
Spliterator.OfInt spl = adapt(spliterator);
|
||||
IntConsumer adaptedSink = adapt(sink);
|
||||
do { } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
|
||||
boolean cancelled;
|
||||
do { } while (!(cancelled = sink.cancellationRequested()) && spl.tryAdvance(adaptedSink));
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -386,6 +388,16 @@ abstract class IntPipeline<E_IN>
|
|||
return SliceOps.makeInt(this, n, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream takeWhile(IntPredicate predicate) {
|
||||
return WhileOps.makeTakeWhileInt(this, predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream dropWhile(IntPredicate predicate) {
|
||||
return WhileOps.makeDropWhileInt(this, predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream sorted() {
|
||||
return SortedOps.makeInt(this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue