mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8319123: Implement JEP 461: Stream Gatherers (Preview)
Reviewed-by: tvaleev, alanb, psandoz
This commit is contained in:
parent
04ad98ed32
commit
33b26f79a9
24 changed files with 4988 additions and 7 deletions
|
@ -90,12 +90,27 @@ abstract class ReferencePipeline<P_IN, P_OUT>
|
|||
* Constructor for appending an intermediate operation onto an existing
|
||||
* pipeline.
|
||||
*
|
||||
* @param upstream the upstream element source.
|
||||
* @param upstream the upstream element source
|
||||
* @param opFlags The operation flags for this operation, described in
|
||||
* {@link StreamOpFlag}
|
||||
*/
|
||||
ReferencePipeline(AbstractPipeline<?, P_IN, ?> upstream, int opFlags) {
|
||||
super(upstream, opFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for appending an intermediate operation onto an existing
|
||||
* pipeline.
|
||||
*
|
||||
* @param upupstream the upstream of the upstream element source
|
||||
* @param upstream the upstream element source
|
||||
* @param opFlags The operation flags for this operation, described in
|
||||
* {@link StreamOpFlag}
|
||||
*/
|
||||
protected ReferencePipeline(AbstractPipeline<?, P_IN, ?> upupstream, AbstractPipeline<?, P_IN, ?> upstream, int opFlags) {
|
||||
super(upupstream, upstream, opFlags);
|
||||
}
|
||||
|
||||
// Shape-specific methods
|
||||
|
||||
@Override
|
||||
|
@ -667,9 +682,14 @@ abstract class ReferencePipeline<P_IN, P_OUT>
|
|||
return evaluate(ReduceOps.makeRef(identity, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> Stream<R> gather(Gatherer<? super P_OUT, ?, R> gatherer) {
|
||||
return GathererOp.of(this, gatherer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <R, A> R collect(Collector<? super P_OUT, A, R> collector) {
|
||||
public <R, A> R collect(Collector<? super P_OUT, A, R> collector) {
|
||||
A container;
|
||||
if (isParallel()
|
||||
&& (collector.characteristics().contains(Collector.Characteristics.CONCURRENT))
|
||||
|
@ -687,7 +707,7 @@ abstract class ReferencePipeline<P_IN, P_OUT>
|
|||
}
|
||||
|
||||
@Override
|
||||
public final <R> R collect(Supplier<R> supplier,
|
||||
public <R> R collect(Supplier<R> supplier,
|
||||
BiConsumer<R, ? super P_OUT> accumulator,
|
||||
BiConsumer<R, R> combiner) {
|
||||
return evaluate(ReduceOps.makeRef(supplier, accumulator, combiner));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue