Is there any reason EnumMap and EnumSet are not Navigable

前端 未结 3 1324
广开言路
广开言路 2020-12-15 03:33

Enum is Comparable which means you can have

NavigableSet modes = new TreeSet<>();
NavigableMap modeMap = ne         


        
3条回答
  •  臣服心动
    2020-12-15 03:52

    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:

    • http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6278287
    • http://www.java.net/node/644910

    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 :-)

提交回复
热议问题