On Jun 15, 2015, at 7:31 PM, Martin Buchholz <marti...@google.com> wrote: > On Mon, Jun 15, 2015 at 10:16 AM, Paul Sandoz <paul.san...@oracle.com> wrote: > On Jun 15, 2015, at 6:34 PM, Martin Buchholz <marti...@google.com> wrote: > > Staring at LinkedTransferQueue.java, I see: > > > > return Spliterators.spliterator > > (a, 0, i, (Spliterator.ORDERED | > > Spliterator.NONNULL | > > Spliterator.CONCURRENT)); > > > > but ... that's a spliterator over an immutable array, so shouldn't we have > > IMMUTABLE instead of CONCURRENT? > > > > The intent here is that the sub-spliterators "inherit" certain > characteristics of their top-level spliterator or source, > > It makes sense for some characteristics to be inherited, like NONNULL. >
And in general for ORDERED, DISTINCT, SORTED. Also, see CopyOnWriteArraySet, that internally uses CopyOnWriteArrayList, but does not report ORDERED. > rather than from that which might be derived from an internal data structure > used to hold a partitioned set of elements. > > Note that the specification of Spliterator.CONCURRENT allows for > sub-spliterators to report SIZED/SUBSIZED. > > How is SIZED/SUBSIZED different from IMMUTABLE ? Spliterators of ArrayList will report SIZED/SUBSIZED but not IMMUTABLE because the list can be modified. > They both describe internal data structures, so yeah ... there is some kind > of leak of implementation details, but these characteristics are there to be > used by clients, so shouldn't we try to make them accurate? > Since the concurrent collection can be modified it would be inaccurate for a spltierator (top or sub) obtained from that collection to report IMMUTABLE. Such spliterators are weakly consistent and may or may not (e.g. if SIZED/SUBSIZED) reflect any modifications subsequent to their construction. > Alternatively: currently some spliterator characteristics describe "this" > spliterator, and some describe the "parent", which is very confusing. It's a subtle area. Certain Spliterator characteristics refer to the (element) source namely, NONULL, IMMUTABLE and CONCURRENT. Paul.