提交 61d932bd 编写于 作者: P psandoz

8024408: Specifications for Collection/List/Set/SortedSet.spliterator() need...

8024408: Specifications for Collection/List/Set/SortedSet.spliterator() need to document if all the (subclass) instances are required to return SIZED spliterators
Reviewed-by: alanb
上级 1da6abc3
...@@ -503,12 +503,10 @@ public interface Collection<E> extends Iterable<E> { ...@@ -503,12 +503,10 @@ public interface Collection<E> extends Iterable<E> {
/** /**
* Creates a {@link Spliterator} over the elements in this collection. * Creates a {@link Spliterator} over the elements in this collection.
* *
* <p>The returned {@code Spliterator} must report the characteristic * Implementations should document characteristic values reported by the
* {@link Spliterator#SIZED}; implementations should document any additional * spliterator. Such characteristic values are not required to be reported
* characteristic values reported by the returned spliterator. If * if the spliterator reports {@link Spliterator#SIZED} and this collection
* this collection contains no elements then the returned spliterator is * contains no elements.
* only required to report {@link Spliterator#SIZED} and is not required to
* report additional characteristic values (if any).
* *
* <p>The default implementation should be overridden by subclasses that * <p>The default implementation should be overridden by subclasses that
* can return a more efficient spliterator. In order to * can return a more efficient spliterator. In order to
...@@ -534,9 +532,11 @@ public interface Collection<E> extends Iterable<E> { ...@@ -534,9 +532,11 @@ public interface Collection<E> extends Iterable<E> {
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the collections's {@code Iterator}. The spliterator inherits the * from the collections's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the collection's iterator. * <em>fail-fast</em> properties of the collection's iterator.
* <p>
* The created {@code Spliterator} reports {@link Spliterator#SIZED}.
* *
* @implNote * @implNote
* The returned {@code Spliterator} additionally reports * The created {@code Spliterator} additionally reports
* {@link Spliterator#SUBSIZED}. * {@link Spliterator#SUBSIZED}.
* *
* <p>If a spliterator covers no elements then the reporting of additional * <p>If a spliterator covers no elements then the reporting of additional
......
...@@ -386,15 +386,18 @@ public interface Set<E> extends Collection<E> { ...@@ -386,15 +386,18 @@ public interface Set<E> extends Collection<E> {
/** /**
* Creates a {@code Spliterator} over the elements in this set. * Creates a {@code Spliterator} over the elements in this set.
* *
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED} and * <p>The {@code Spliterator} reports {@link Spliterator#DISTINCT}.
* {@link Spliterator#DISTINCT}. Implementations should document the * Implementations should document the reporting of additional
* reporting of additional characteristic values. * characteristic values.
* *
* @implSpec * @implSpec
* The default implementation creates a * The default implementation creates a
* <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
* from the set's {@code Iterator}. The spliterator inherits the * from the set's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the set's iterator. * <em>fail-fast</em> properties of the set's iterator.
* <p>
* The created {@code Spliterator} additionally reports
* {@link Spliterator#SIZED}.
* *
* @implNote * @implNote
* The created {@code Spliterator} additionally reports * The created {@code Spliterator} additionally reports
......
...@@ -223,10 +223,10 @@ public interface SortedSet<E> extends Set<E> { ...@@ -223,10 +223,10 @@ public interface SortedSet<E> extends Set<E> {
/** /**
* Creates a {@code Spliterator} over the elements in this sorted set. * Creates a {@code Spliterator} over the elements in this sorted set.
* *
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED}, * <p>The {@code Spliterator} reports {@link Spliterator#DISTINCT},
* {@link Spliterator#DISTINCT}, {@link Spliterator#SORTED} and * {@link Spliterator#SORTED} and {@link Spliterator#ORDERED}.
* {@link Spliterator#ORDERED}. Implementations should document the * Implementations should document the reporting of additional
* reporting of additional characteristic values. * characteristic values.
* *
* <p>The spliterator's comparator (see * <p>The spliterator's comparator (see
* {@link java.util.Spliterator#getComparator()}) must be {@code null} if * {@link java.util.Spliterator#getComparator()}) must be {@code null} if
...@@ -240,6 +240,9 @@ public interface SortedSet<E> extends Set<E> { ...@@ -240,6 +240,9 @@ public interface SortedSet<E> extends Set<E> {
* from the sorted set's {@code Iterator}. The spliterator inherits the * from the sorted set's {@code Iterator}. The spliterator inherits the
* <em>fail-fast</em> properties of the set's iterator. The * <em>fail-fast</em> properties of the set's iterator. The
* spliterator's comparator is the same as the sorted set's comparator. * spliterator's comparator is the same as the sorted set's comparator.
* <p>
* The created {@code Spliterator} additionally reports
* {@link Spliterator#SIZED}.
* *
* @implNote * @implNote
* The created {@code Spliterator} additionally reports * The created {@code Spliterator} additionally reports
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 8020156 8020009 8022326 8012913 8024405 * @bug 8020156 8020009 8022326 8012913 8024405 8024408
* @run testng SpliteratorCharacteristics * @run testng SpliteratorCharacteristics
*/ */
...@@ -46,6 +46,7 @@ import java.util.Spliterator; ...@@ -46,6 +46,7 @@ import java.util.Spliterator;
import java.util.Spliterators; import java.util.Spliterators;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.ConcurrentSkipListSet;
import java.util.function.Supplier; import java.util.function.Supplier;
...@@ -185,6 +186,11 @@ public class SpliteratorCharacteristics { ...@@ -185,6 +186,11 @@ public class SpliteratorCharacteristics {
Spliterator.SIZED | Spliterator.DISTINCT); Spliterator.SIZED | Spliterator.DISTINCT);
} }
public void testWeakHashMap() {
assertMapCharacteristics(new WeakHashMap<>(),
Spliterator.DISTINCT);
}
public void testHashSet() { public void testHashSet() {
assertSetCharacteristics(new HashSet<>(), assertSetCharacteristics(new HashSet<>(),
Spliterator.SIZED | Spliterator.DISTINCT); Spliterator.SIZED | Spliterator.DISTINCT);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册