You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that with the current libraries API the best I can do is O(n).
It would be convenient to implement a TreeMap so we can have an OrderedMap that can be navigated via a NavigableMap. The lowerKey() and higherKey() methods return the next and previous keys. This simply keeps track of three nodes (next, current, and previous). Although I know SortedMap is also under consideration and that would be nice to have alongside this.
If you were to achieve a more performant lookup I imagine it would be similar to what users are doing for SortedMap right now. Which is to maintain an array of the keys. Then you can use the index of the current key in order to get the previous or next keys.
If anyone has any other tips or ways of achieving this I would love to hear about them!
Given a key that is in an OrderedMap, is there an efficient way (O(1) or O(log n)) to get the next or previous item?
The text was updated successfully, but these errors were encountered: