i havent looked into the switch, but EnumSet certainly relies on ordinal() as per seen in the implementations RegularEnumSet and JumboEnumSet
there must be a reason to why they dont implement SortedSet as they were written by none other than Joshua Bloch - or maybe he just forgot about that? On Thu, Jul 30, 2009 at 7:56 PM, Casper Bang<[email protected]> wrote: > > You are not really suppose to rely on the ordinal, it's an impl detail > that can admittedly be hard to ignore when you're used to the old > integer enum pattern. The internals of an Enum and EnumSet does a lot > of magic, as you can see by decompiling an example. For instance, a > switch on an Enum does not rely on the ordinals directly (javac builds > a statically-generated table) and in most cases an EnumSet is > represented as a long. > > /Casper > > On 30 Jul., 11:56, drd <[email protected]> wrote: >> I was wondering: why is an EnumSet not a SortedSet. >> >> Javadoc of EnumSet says : ... the iterator returns the elements in >> their natural order ... >> >> Javadoc of SortedSet says: A Set that further provides a total >> ordering on its elements. The elements are ordered using their natural >> ordering, or by a Comparator typically provided at sorted set creation >> time... >> >> Why is then the EnumSet not a SortedSet? >> >> I hope somebody will be able to clarify my mind. > > > -- http://mapsdev.blogspot.com/ Marcelo Takeshi Fukushima --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
