< prev index next >

src/java.base/share/classes/java/util/Collection.java

Print this page




 520      * preserve expected laziness behavior for the {@link #stream()} and
 521      * {@link #parallelStream()} methods, spliterators should either have the
 522      * characteristic of {@code IMMUTABLE} or {@code CONCURRENT}, or be
 523      * <em><a href="Spliterator.html#binding">late-binding</a></em>.
 524      * If none of these is practical, the overriding class should describe the
 525      * spliterator's documented policy of binding and structural interference,
 526      * and should override the {@link #stream()} and {@link #parallelStream()}
 527      * methods to create streams using a {@code Supplier} of the spliterator,
 528      * as in:
 529      * <pre>{@code
 530      *     Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)
 531      * }</pre>
 532      * <p>These requirements ensure that streams produced by the
 533      * {@link #stream()} and {@link #parallelStream()} methods will reflect the
 534      * contents of the collection as of initiation of the terminal stream
 535      * operation.
 536      *
 537      * @implSpec
 538      * The default implementation creates a
 539      * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
 540      * from the collections's {@code Iterator}.  The spliterator inherits the
 541      * <em>fail-fast</em> properties of the collection's iterator.
 542      * <p>
 543      * The created {@code Spliterator} reports {@link Spliterator#SIZED}.
 544      *
 545      * @implNote
 546      * The created {@code Spliterator} additionally reports
 547      * {@link Spliterator#SUBSIZED}.
 548      *
 549      * <p>If a spliterator covers no elements then the reporting of additional
 550      * characteristic values, beyond that of {@code SIZED} and {@code SUBSIZED},
 551      * does not aid clients to control, specialize or simplify computation.
 552      * However, this does enable shared use of an immutable and empty
 553      * spliterator instance (see {@link Spliterators#emptySpliterator()}) for
 554      * empty collections, and enables clients to determine if such a spliterator
 555      * covers no elements.
 556      *
 557      * @return a {@code Spliterator} over the elements in this collection
 558      * @since 1.8
 559      */
 560     @Override




 520      * preserve expected laziness behavior for the {@link #stream()} and
 521      * {@link #parallelStream()} methods, spliterators should either have the
 522      * characteristic of {@code IMMUTABLE} or {@code CONCURRENT}, or be
 523      * <em><a href="Spliterator.html#binding">late-binding</a></em>.
 524      * If none of these is practical, the overriding class should describe the
 525      * spliterator's documented policy of binding and structural interference,
 526      * and should override the {@link #stream()} and {@link #parallelStream()}
 527      * methods to create streams using a {@code Supplier} of the spliterator,
 528      * as in:
 529      * <pre>{@code
 530      *     Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)
 531      * }</pre>
 532      * <p>These requirements ensure that streams produced by the
 533      * {@link #stream()} and {@link #parallelStream()} methods will reflect the
 534      * contents of the collection as of initiation of the terminal stream
 535      * operation.
 536      *
 537      * @implSpec
 538      * The default implementation creates a
 539      * <em><a href="Spliterator.html#binding">late-binding</a></em> spliterator
 540      * from the collection's {@code Iterator}.  The spliterator inherits the
 541      * <em>fail-fast</em> properties of the collection's iterator.
 542      * <p>
 543      * The created {@code Spliterator} reports {@link Spliterator#SIZED}.
 544      *
 545      * @implNote
 546      * The created {@code Spliterator} additionally reports
 547      * {@link Spliterator#SUBSIZED}.
 548      *
 549      * <p>If a spliterator covers no elements then the reporting of additional
 550      * characteristic values, beyond that of {@code SIZED} and {@code SUBSIZED},
 551      * does not aid clients to control, specialize or simplify computation.
 552      * However, this does enable shared use of an immutable and empty
 553      * spliterator instance (see {@link Spliterators#emptySpliterator()}) for
 554      * empty collections, and enables clients to determine if such a spliterator
 555      * covers no elements.
 556      *
 557      * @return a {@code Spliterator} over the elements in this collection
 558      * @since 1.8
 559      */
 560     @Override


< prev index next >