Doug Lea dl at cs.oswego.edu
Sun Feb 10 13:00:27 PST 2013

On 02/10/13 12:25, Remi Forax wrote:
> Playing a little bit with how findFirst/forEachUntil can be implemented on top
> of a Spliterator,
> I think that tryAdvance should be changed to be able to return a value produced
> in the middle of the consumer taken by tryAdvance.

Brian and I spent a while on this theme, of only supporting
forEach and some variant of the search method I mentioned.
If we had nonnull-element guarantees, it would be an easier call:
just use CHM-like search. The primitive int/long/double
versions would  need a boxed return value but these could
sometimes be optimized away in practice. All in all seems
pretty good. But when you also allow nullable elements,
it means that every call is guaranteed to create a nuisance
object, which makes it less attractive than single-step
tryAdvance as the basic workhorse underlying a lot of bulk

>    /**
>     * Sentinel value used by tryAdvance to signal that there is no more element.
>     */
>    public static final Object END = new Object();

No can do. (Primitives.)


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