Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • That sucks, I was hoping to get access to .previous() and .next() in O(1) instead of looping through the entries in O(n) to get the previous and next. Commented Nov 16, 2016 at 21:15
  • 2
    @WinterDev next() is O(1) Commented Nov 16, 2016 at 21:17
  • 2
    @PeterLawrey If I have a key K and want to get the equivalent of K.next(), I have to loop through the iterator until I find K and then get the next one, which is O(n) Commented Nov 16, 2016 at 21:19
  • 4
    @WinterDev in that case,t his is not an intended use case for this Map. I suggest using a NavigableMap which has next and previous. Commented Nov 16, 2016 at 21:20
  • 1
    @WinterDev it's O(log n) like basically all other operations. Commented Nov 16, 2016 at 21:56