Is there any reason EnumMap and EnumSet are not Navigable

前端 未结 3 1331
广开言路
广开言路 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:57

    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

提交回复
热议问题