changeset 6655:6a8f5382f238

Merge
author briangoetz
date Fri, 30 Nov 2012 15:56:47 -0500
parents 96f7957e8b39 1e85112dff65
children 93ad4413f0ce
files src/share/classes/java/util/stream/AbstractPipeline.java src/share/classes/java/util/stream/Streams.java
diffstat 3 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/AbstractPipeline.java	Fri Nov 30 15:55:04 2012 -0500
+++ b/src/share/classes/java/util/stream/AbstractPipeline.java	Fri Nov 30 15:56:47 2012 -0500
@@ -192,7 +192,7 @@
 
                 // Get the source flags for the intermediate stream
                 iSourceFlags = StreamOpFlag.toStreamFlags(StreamOpFlag.combineOpFlags(statefulOp.getOpFlags(), opsFlags[upToOp]))
-                               | StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED;
+                               | StreamOpFlag.IS_SIZED;
                 iSource = new StreamSource.ForSpliterator<>(iNode.spliterator());
 
                 fromOp = ++upToOp;
@@ -620,7 +620,7 @@
                         for (int i = 0; i < subDepth; i++) {
                             flags = StreamOpFlag.combineOpFlags(ops[i].getOpFlags(), flags);
                         }
-                        flags = StreamOpFlag.toStreamFlags(flags) | StreamOpFlag.IS_SIZED | StreamOpFlag.IS_ORDERED;
+                        flags = StreamOpFlag.toStreamFlags(flags) | StreamOpFlag.IS_SIZED;
 
                         // Wrap the spliterator in a wrapping spliterator
                         s = wrappingSpliterator(new StreamSource.ForSpliterator<>(s), flags, subDepth, depth);
--- a/src/share/classes/java/util/stream/Streams.java	Fri Nov 30 15:55:04 2012 -0500
+++ b/src/share/classes/java/util/stream/Streams.java	Fri Nov 30 15:56:47 2012 -0500
@@ -168,12 +168,7 @@
     }
 
     public static<T> Stream<T> repeat(final int n, final T t) {
-        if (n < 0) {
-            InfiniteIterator<T> iterator = () -> t;
-            return stream(new StreamSource.ForIterator<>(iterator), StreamOpFlag.IS_ORDERED);
-        }
-        else
-            return repeatedly(n, () -> t);
+        return repeatedly(n, () -> t);
     }
 
     public static<T> Stream<T> repeatedly(Supplier<T> f) {
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java	Fri Nov 30 15:55:04 2012 -0500
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/op/FlagOpTest.java	Fri Nov 30 15:56:47 2012 -0500
@@ -219,24 +219,26 @@
     }
 
     protected void testFlagsClearSequence(Supplier<StatefulOp<Integer, Integer>> cf) {
+        EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
         EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
         EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
 
         List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();
-        for (StreamOpFlag f : EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
+        for (StreamOpFlag f : EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
             ops.add(cf.get());
             ops.add(new TestFlagExpectedOp<>(f.clear(),
-                                             EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED),
+                                             known.clone(),
                                              preserve.clone(),
-                                             notKnown));
+                                             notKnown.clone()));
+            known.remove(f);
+            preserve.remove(f);
             notKnown.add(f);
-            preserve.remove(f);
         }
         ops.add(cf.get());
         ops.add(new TestFlagExpectedOp<>(0,
-                                         EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED),
+                                         known.clone(),
                                          preserve.clone(),
-                                         EnumSet.noneOf(StreamOpFlag.class)));
+                                         notKnown.clone()));
 
         StreamTestData<Integer> data = new StreamTestData.ArrayData<>("Array", countTo(10).toArray(new Integer[0]));
         @SuppressWarnings("rawtypes")
@@ -249,7 +251,7 @@
     }
 
     public void testFlagsSizedOrderedParallelCollect() {
-        EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
+        EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
         EnumSet<StreamOpFlag> serKnown = parKnown.clone();
 
         List<IntermediateOp<Integer, Integer>> ops = new ArrayList<>();