Loose ends: PrimitiveIterator.forEachRemaining(T_CONS action)

Paul Sandoz paul.sandoz at oracle.com
Thu May 30 02:00:06 PDT 2013

We recently added Spliterator.OfPrimitive and it has proved very useful reducing some primitive-based spliterator code, specifically wrapping-based spliterators, such as for concatenation.

The same technique can be applied to PrimitiveIterator; a method forEachRemaining(T_CONS action) can be defined:

    public interface PrimitiveIterator<T, T_CONS> extends Iterator<T> {
        void forEachRemaining(T_CONS action);

This has little or no impact on the current implementation, since PrimitiveIterator is not widely used. However, i still think there are some advantages:

1) consistency with Spliterator.OfPrimitive; and

2) there may be cases in the future where this is useful and if we don't do it now it becomes difficult to do so later on.

The change could be categorised as "mostly harmless and potentially useful in the future".


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