Spliterator flags as enum (was Initial java.util.Spliterator putback)

Doug Lea dl at cs.oswego.edu
Thu Mar 28 18:45:44 UTC 2013


On 03/28/13 13:18, Tim Peierls wrote:
> I can't find a discussion of why Spliterator flags are ints rather than enum.

We started out with enums on (my) initial Spliterator side vs
control flags internal to streams. The we had to somehow
mesh these to work together. On the stream side, you need
to set and unset various bits across stages. Clearly
you can't do that to someone's EnumSet -- they will not expect
you to modify it, but enforcing this makes it both unwieldy and
sleaze-inducing (we'd have to grab underlying representation from
EnumSet).

Another way of saying this is that we needed an efficient
propagate-by-value small-N bit set mechanism, and the only candidate
was the traditional one. This amounts to the same reason
that nio "interest" flags are done the same way.

-Doug








More information about the core-libs-dev mailing list