Enum is Comparable which means you can have
NavigableSet modes = new TreeSet<>();
NavigableMap modeMap = ne
Many "obvious" features are missing from the JDK and its various APIs. Why this particular feature was omitted / forgotten? We can only guess. But your question has been a RFE at Sun/Oracle for a long time:
You could support those RFEs by commenting on them. Note, here's an authoritative answer by Joshua Bloch on the subject:
I vaguely recall considering it, but I can't recall whether we explicitly rejected it with good reason. We were running very low on time when I implemented EnumSet and EnumMap, and it's possible that time played a role in our decision
http://comments.gmane.org/gmane.comp.java.jsr.166-concurrency/2158
So even he had to guess :-)
My best guess is that navigability was not seen as a major use case for enum sets. There is nothing in the implementation that would prevent navigability. The rare use cases that combine the need for a set of enum members with navigability are covered by the TreeSet
and TreeMap
.
The post doesn't directly answers the question, neither attempts to, it merely conveys why Navigable was introduced
Post as I was requested to (and it's too long for a comment)
The short answer is that Navigable exists because we didn't have anything like upcoming "defenders" -- Sorted didn't describe all the common functionality, and there was no way to do so except to introduce a new interface. In practice, I'm sure "Sorted" is still used much more often than "Navigable" as a declaration type, because most people don't need the methods defined in Navigable but not Sorted. Plus "Navigable" is just not a very nice name :-)
-Doug