Partager via


ICollection.IIterable.Spliterator Method

Definition

Creates a Spliterator over the elements in this collection.

[Android.Runtime.Register("spliterator", "()Ljava/util/Spliterator;", "GetSpliteratorHandler:Java.Util.ICollection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=24)]
override sealed Java.Util.ISpliterator IIterable.Spliterator ();
[<Android.Runtime.Register("spliterator", "()Ljava/util/Spliterator;", "GetSpliteratorHandler:Java.Util.ICollection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=24)>]
abstract member Java.Lang.IIterable.Spliterator : unit -> Java.Util.ISpliterator
override this.Java.Lang.IIterable.Spliterator : unit -> Java.Util.ISpliterator

Returns

a Spliterator over the elements in this collection

Implements

Attributes

Remarks

Creates a Spliterator over the elements in this collection.

Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator#SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the #stream() and #parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be <em>late-binding</em>. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the #stream() and #parallelStream() methods to create streams using a Supplier of the spliterator, as in:

{@code
                Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)
            }

These requirements ensure that streams produced by the #stream() and #parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Added in 1.8.

Java documentation for java.util.Collection.spliterator().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to