changeset 7842:2bf9b8b3f119

Simplify spliterator reporting SORTED.
author psandoz
date Mon, 08 Apr 2013 18:58:27 +0200
parents 3a84da0da6dc
children a3c75453c6c1
files test-ng/tests/org/openjdk/tests/java/util/stream/DistinctOpTest.java
diffstat 1 files changed, 3 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/test-ng/tests/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Mon Apr 08 18:52:46 2013 +0200
+++ b/test-ng/tests/org/openjdk/tests/java/util/stream/DistinctOpTest.java	Mon Apr 08 18:58:27 2013 +0200
@@ -35,6 +35,7 @@
 import java.util.List;
 import java.util.SortedSet;
 import java.util.Spliterator;
+import java.util.Spliterators;
 import java.util.TreeSet;
 import java.util.function.Consumer;
 import java.util.stream.*;
@@ -96,47 +97,8 @@
 
         @Override
         public Spliterator<T> spliterator() {
-            class SortedSpliterator implements Spliterator<T> {
-
-                final Spliterator<T> s;
-
-                SortedSpliterator(Spliterator<T> s) {
-                    this.s = s;
-                }
-
-                @Override
-                public boolean tryAdvance(Consumer<? super T> action) {
-                    return s.tryAdvance(action);
-                }
-
-                @Override
-                public void forEachRemaining(Consumer<? super T> action) {
-                    s.forEachRemaining(action);
-                }
-
-                @Override
-                public Spliterator<T> trySplit() {
-                    Spliterator<T> split = s.trySplit();
-                    if (split == null) return null;
-                    return new SortedSpliterator(split);
-                }
-
-                @Override
-                public long estimateSize() {
-                    return s.estimateSize();
-                }
-
-                @Override
-                public int characteristics() {
-                    return s.characteristics() | Spliterator.SORTED;
-                }
-
-                @Override
-                public Comparator<? super T> getComparator() {
-                    return null;
-                }
-            }
-            return new SortedSpliterator(c.spliterator());
+            return Spliterators.spliterator(c.toArray(),
+                                            Spliterator.ORDERED | Spliterator.SORTED);
         }
 
         @Override