changeset 6360:ec1d4918ad00

Remove StreamOpFlags.INFINITELY_SIZED. Some places where getSizeIfKnown() returns -1 or an op clears the size now potentially means it may be infinite (just not known to be).
author psandoz
date Tue, 30 Oct 2012 16:07:58 -0700
parents 90896528e6ab
children ef437fbf4a28
files src/share/classes/java/util/streams/AbstractPipeline.java src/share/classes/java/util/streams/PipelineHelper.java src/share/classes/java/util/streams/StreamOpFlags.java src/share/classes/java/util/streams/Streams.java src/share/classes/java/util/streams/ops/LimitOp.java test-ng/tests/org/openjdk/tests/java/util/streams/StreamOpFlagsTest.java
diffstat 6 files changed, 4 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/streams/AbstractPipeline.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/src/share/classes/java/util/streams/AbstractPipeline.java	Tue Oct 30 16:07:58 2012 -0700
@@ -192,11 +192,6 @@
         }
 
         @Override
-        public boolean isOutputInfinitelySized() {
-            return StreamOpFlags.INFINITELY_SIZED.isKnown(sourceAndOpsFlags);
-        }
-
-        @Override
         public Sink<P_IN> wrapSink(Sink sink) {
             Objects.requireNonNull(sink);
 
--- a/src/share/classes/java/util/streams/PipelineHelper.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/src/share/classes/java/util/streams/PipelineHelper.java	Tue Oct 30 16:07:58 2012 -0700
@@ -49,12 +49,6 @@
     int getOutputSizeIfKnown();
 
     /**
-     *
-     * @return true if the output stream is known to be infintely sized, otherwise false.
-     */
-    boolean isOutputInfinitelySized();
-
-    /**
      * Wrap a sink (see {@link #wrapSink(Sink)} that corresponds to the sink that
      * accepts elements output from the pipeline, then push all elements obtained
      * from the stream accessor into that wrapped sink.
--- a/src/share/classes/java/util/streams/StreamOpFlags.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/src/share/classes/java/util/streams/StreamOpFlags.java	Tue Oct 30 16:07:58 2012 -0700
@@ -44,9 +44,7 @@
 
     SIZED(3),
 
-    INFINITELY_SIZED(4),
-
-    SHORT_CIRCUIT(5, false)
+    SHORT_CIRCUIT(4, false)
     ;
 
     /**
@@ -179,7 +177,6 @@
     /**
      * The size of the stream is known to be calculated in less than {@code O(n)} time and that
      * size is known to be equal to the size of the stream source.
-     * <p>Mutually exclusive to {@link #IS_INFINITELY_SIZED}.</p>
      */
     public static final int IS_SIZED = SIZED.set;
 
@@ -189,17 +186,6 @@
     public static final int NOT_SIZED = SIZED.clear;
 
     /**
-     * The size of stream is known to be infinitely sized.
-     * <p>Mutually exclusive to {@link #IS_SIZED}.</p>
-     */
-    public static final int IS_INFINITELY_SIZED = INFINITELY_SIZED.set;
-
-    /**
-     * The size of the stream not known to the inifinitely sized.
-     */
-    public static final int NOT_INFINITELY_SIZED = INFINITELY_SIZED.clear;
-
-    /**
      * The stream is known to be short circuited. Evaluation of the pipeline is constrained to be
      * pull-oriented.  This is true for operations that may truncate or otherwise
      * manipulate the stream contents.
--- a/src/share/classes/java/util/streams/Streams.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/src/share/classes/java/util/streams/Streams.java	Tue Oct 30 16:07:58 2012 -0700
@@ -370,7 +370,7 @@
         @Override
         public int getStreamFlags() {
             // @@@ Should encounter order be set by default?
-            return StreamOpFlags.IS_INFINITELY_SIZED | StreamOpFlags.IS_ORDERED;
+            return StreamOpFlags.IS_ORDERED;
         }
 
         @Override
--- a/src/share/classes/java/util/streams/ops/LimitOp.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/src/share/classes/java/util/streams/ops/LimitOp.java	Tue Oct 30 16:07:58 2012 -0700
@@ -46,7 +46,7 @@
 
     @Override
     public int getOpFlags() {
-        return StreamOpFlags.NOT_SIZED | StreamOpFlags.NOT_INFINITELY_SIZED | StreamOpFlags.IS_SHORT_CIRCUIT;
+        return StreamOpFlags.NOT_SIZED | StreamOpFlags.IS_SHORT_CIRCUIT;
     }
 
     @Override
@@ -66,9 +66,7 @@
         // Dumb serial implementation defering to iterator
         final Iterator<T> i = wrapIterator(helper.getStreamFlags(), helper.iterator());
 
-        final int size = helper.isOutputInfinitelySized()
-                         ? limit
-                         : Math.min(helper.getOutputSizeIfKnown(), limit);
+        final int size = Math.min(helper.getOutputSizeIfKnown(), limit);
 
         final NodeBuilder<T> nb = Nodes.makeBuilder(size);
 
--- a/test-ng/tests/org/openjdk/tests/java/util/streams/StreamOpFlagsTest.java	Tue Oct 30 15:53:43 2012 -0700
+++ b/test-ng/tests/org/openjdk/tests/java/util/streams/StreamOpFlagsTest.java	Tue Oct 30 16:07:58 2012 -0700
@@ -51,13 +51,11 @@
         assertTrue(StreamOpFlags.DISTINCT.isKnown(flags));
         assertTrue(StreamOpFlags.SORTED.isKnown(flags));
         assertTrue(StreamOpFlags.ORDERED.isKnown(flags));
-        assertFalse(StreamOpFlags.INFINITELY_SIZED.isKnown(flags));
 
         assertFalse(StreamOpFlags.SIZED.isKnownOnOpFlags(flags));
         assertTrue(StreamOpFlags.DISTINCT.isKnownOnOpFlags(flags));
         assertTrue(StreamOpFlags.SORTED.isKnownOnOpFlags(flags));
         assertTrue(StreamOpFlags.ORDERED.isKnownOnOpFlags(flags));
-        assertTrue(StreamOpFlags.INFINITELY_SIZED.isKnownOnOpFlags(flags));
     }
 
 }