Enum is Comparable which means you can have
NavigableSet<AccessMode> modes = new TreeSet<>();
NavigableMap<AccessMode, Object> modeMap = new TreeMap<>();
These have O(ln N) access times.
The Enum collections have O(1) access times, but are not Navigable
NavigableSet<AccessMode> modes = EnumSet.noneOf(AccessMode.class); // doesn't compile
NavigableMap<AccessMode, Object> modeMap = new EnumMap<>(AccessMode.class); // doesn't compile
I was wondering if there was a reason Enum collections were not Navigable (and Sorted). i.e Am I missing something?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…