Spliterator (original) (raw)

Doug Lea dl at cs.oswego.edu
Wed Dec 19 06:38:31 PST 2012


On 12/19/12 09:19, Brian Goetz wrote:

We use split() to build a tree of splits; this is mirrored by a tree of FJTs. I use this information to determine when split() is creating a new level of the tree, and when it is creating a new sibling at the same level.

T firstChild = makeChild(spliterator.split()); setPendingCount(naturalSplits); numChildren = naturalSplits + 1; children = firstChild; T curChild = firstChild; for (int i=naturalSplits-1; i >= 0; i--) { T newChild = makeChild((i > 0) ? spliterator.split() : spliterator); curChild.nextSibling = newChild; curChild = newChild; }

I'm trying hard to see the context or spec wording that would make this useful.

Each time you call s.split, some fraction of s is split off. So it seems that the value you want here is something like: "return the number of times to split before you are logically at the next depth level, if such a level exists"?

Which will be hard to state clearly.

Do you have any existing examples of Spliterators that return values other than 1/0? That might help.

The point is: I see value to the possibility of arranging spliterators in other than a binary tree.

No, nothing (explicitly) about binary trees, only about supporting an incremental usage model. As in: split; maybe split some more; ...

-Doug



More information about the lambda-libs-spec-experts mailing list