changeset 7833:2eafb34235ba

Clarify some behvaiour of the wrapping spliterator used for creating a spliterator from a pipeline.
author psandoz
date Mon, 08 Apr 2013 14:58:35 +0200
parents 2fd5a66fed96
children 92de05e3de00
files src/share/classes/java/util/stream/StreamSpliterators.java
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/StreamSpliterators.java	Sun Apr 07 18:26:04 2013 -0400
+++ b/src/share/classes/java/util/stream/StreamSpliterators.java	Mon Apr 08 14:58:35 2013 +0200
@@ -43,11 +43,19 @@
     /**
      * Abstract wrapping spliterator that binds to the spliterator of a
      * pipeline helper on first operation.
-     * @@@ If Spliterator.SUBSIZED was propagated as a stream flag through
-     * the pipeline this class could be converted to a late-binding spliterator
+     *
+     * <p>This spliterator is not late-binding and will bind to the source
+     * spliterator when first operated on.
+     *
+     * <p>A wrapping spliterator produced from a sequential stream
+     * cannot be split if there are stateful operations present.
      */
     private static abstract class AbstractWrappingSpliterator<P_IN, P_OUT, T_BUFFER extends AbstractSpinedBuffer<P_OUT>>
             implements Spliterator<P_OUT> {
+
+        // @@@ Detect if stateful operations are present or not
+        //     If not then can split otherwise cannot
+
         // True if this spliterator supports splitting
         final boolean isParallel;
 
@@ -177,15 +185,12 @@
             // Get the characteristics from the pipeline
             int c = StreamOpFlag.toCharacteristics(StreamOpFlag.toStreamFlags(ph.getStreamAndOpFlags()));
 
-            // @@@ determining if the source spliterator is SUBSIZED results in
-            // in the wrapping spliterator not being late-binding
-            // to fix this requires that SUBSIZED is mapped to a stream flag
-            // and propagated through the pipeline
-
-            // Mask off the size and uniform characteristics and replace with those of the spliterator
-            // Note that a non-uniform spliterator can change from something with an exact size to an
-            // estimate for a sub-split, for example with HashSet where the size is known at the top
-            // level spliterator but for sub-splits only an estimate is known
+            // Mask off the size and uniform characteristics and replace with
+            // those of the spliterator
+            // Note that a non-uniform spliterator can change from something
+            // with an exact size to an estimate for a sub-split, for example
+            // with HashSet where the size is known at the top level spliterator
+            // but for sub-splits only an estimate is known
             if ((c & Spliterator.SIZED) != 0) {
                 c &= ~(Spliterator.SIZED | Spliterator.SUBSIZED);
                 c |= (spliterator.characteristics() & Spliterator.SIZED & Spliterator.SUBSIZED);