OpenJDK / lambda / lambda / jdk
changeset 5873:e4e2682c1d16 it2-bootstrap
More JavaDoc
author | mduigou |
---|---|
date | Tue, 28 Aug 2012 15:09:36 -0700 |
parents | debae4fe344f |
children | 27d79f2d4b46 |
files | src/share/classes/java/util/Spliterator.java src/share/classes/java/util/streams/AbstractPipeline.java src/share/classes/java/util/streams/StreamAccessor.java src/share/classes/java/util/streams/ops/TreeUtils.java |
diffstat | 4 files changed, 48 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/util/Spliterator.java Tue Aug 28 16:52:28 2012 -0400 +++ b/src/share/classes/java/util/Spliterator.java Tue Aug 28 15:09:36 2012 -0700 @@ -50,10 +50,17 @@ void forEach(Sink<? super T> sink); /** - * Get the number of elements remaining to be processed, if it can be computed exactly and cheaply. Otherwise, return -1. - * @return The number of remaining elements, or -1 if unknown + * Return the number of elements remaining to be processed, if the count can + * be computed exactly and cheaply. Otherwise, return -1. + * + * @return The number of remaining elements, or negative value if unknown */ int getRemainingSizeIfKnown() default { return -1; } + /** + * Return {@code true} if this spliterator returns symmetric splits. + * + * @return {@code true} if this spliterator returns symmetric splits. + */ boolean isPredictableSplits() default { return false; } }
--- a/src/share/classes/java/util/streams/AbstractPipeline.java Tue Aug 28 16:52:28 2012 -0400 +++ b/src/share/classes/java/util/streams/AbstractPipeline.java Tue Aug 28 15:09:36 2012 -0700 @@ -33,6 +33,9 @@ /** * AbstractPipeline * + * @param <T> Type of input elements. + * @param <U> Type of output elements. + * * @author Brian Goetz */ public abstract class AbstractPipeline<T, U> { @@ -41,8 +44,16 @@ protected final IntermediateOp<T,U> op; protected final int depth; + /** + * If non-{@code null} then we are in serial iteration mode. + */ private Iterator<U> iterator; + /** + * Constructor for the element source of a pipeline. + * + * @param source element source + */ protected AbstractPipeline(StreamAccessor<?> source) { this.source = Objects.requireNonNull(source); this.op = null; @@ -50,6 +61,12 @@ this.depth = 0; } + /** + * Constructor for a pipeline operation. + * + * @param upstream the upstream element source. + * @param op the operation performed upon elements. + */ protected AbstractPipeline(AbstractPipeline<?, T> upstream, IntermediateOp<T,U> op) { this.upstream = Objects.requireNonNull(upstream); this.op = Objects.requireNonNull(op);
--- a/src/share/classes/java/util/streams/StreamAccessor.java Tue Aug 28 16:52:28 2012 -0400 +++ b/src/share/classes/java/util/streams/StreamAccessor.java Tue Aug 28 15:09:36 2012 -0700 @@ -31,6 +31,8 @@ /** * StreamAccessor * + * @param <T> Type of elements + * * @author Brian Goetz */ public interface StreamAccessor<T> { @@ -42,11 +44,27 @@ public int getSizeOrEstimate(); + /** + * If {@code true} then source is usable from multiple threads simultaneously. + * + * @return {@code true} then source is usable from multiple threads + * simultaneously. + */ boolean isParallel(); + /** + * Returns {@code true} if this stream returns symmetric splits. + * @return {@code true} if this stream returns symmetric splits. + */ boolean isPredictableSplits(); Stream.Shape getShape(); + /** + * Returns a spliterator for this stream. Must be requested before + * {@code iterator()} is called. + * + * @return a spliterator for this stream. + */ Spliterator<T> spliterator(); }
--- a/src/share/classes/java/util/streams/ops/TreeUtils.java Tue Aug 28 16:52:28 2012 -0400 +++ b/src/share/classes/java/util/streams/ops/TreeUtils.java Tue Aug 28 15:09:36 2012 -0700 @@ -36,6 +36,10 @@ * @author Brian Goetz */ public class TreeUtils { + private TreeUtils() { + throw new Error("no instances"); + } + // @@@ This method is a hack, in that helper.sink() might serve up a stateful sink. // This logic should be more tightly reflected in the helper rather than expecting every client to // do instanceof and casts.