Java Reference
In-Depth Information
Characteristic Meaning
DISTINCT
For each pair of traversed elements x and y, x.equals(y) returns false.
SORTED
The traversed elements follow a predefined sort order.
SIZED
This Spliterator has been created from a source with a known size (for example, a Set),
so the value returned by estimatedSize() is precise.
NONNULL
It's guaranteed that the traversed elements won't be null.
IMMUTABLE
The source of this Spliterator can't be modified. This implies that no elements can be
added, removed, or modified during their traversal.
CONCURRENT
The source of this Spliterator may be safely concurrently modified by other threads
without any synchronization.
SUBSIZED
Both this Spliterator and all further Spliterators resulting from its split are SIZED.
Now that you've seen what the Spliterator interface is and which methods it defines, you can try
to develop your own implementation of a Spliterator.
7.3.2. Implementing your own Spliterator
Let's look at a practical example of where you might need to implement your own Spliterator.
We'll develop a simple method that counts the number of words in a String. An iterative version
of this method could be written as shown in the following listing.
 
Search WWH ::




Custom Search