Spliterators of iterators

Martin Buchholz martinrb at google.com
Wed Jun 17 06:10:57 UTC 2015


On Tue, Jun 16, 2015 at 1:43 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:

>
> It's a subtle area. Certain Spliterator characteristics refer to the
> (element) source namely, NONULL, IMMUTABLE and CONCURRENT.
>

 Yes, it's  subtle.  I went back and studied
http://download.java.net/jdk9/docs/api/java/util/Spliterator.html#CONCURRENT

It strongly suggests that CONCURRENT always refers to the original source
(top-level Spliterator) while SIZED and IMMUTABLE refer to "this"
spliterator.  Most surprisingly, it suggests that LTQSpliterator.trySplit
should return a spliterator that is both CONCURRENT and IMMUTABLE.

"""A top-level Spliterator should not report both CONCURRENT and IMMUTABLE,
since they are mutually exclusive. Such a Spliterator is inconsistent and
no guarantees can be made about any computation using that Spliterator.
Sub-spliterators may report IMMUTABLE if additions or removals to the
source are not reflected when traversing."""



More information about the core-libs-dev mailing list