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.

Required fields*

2
  • Note: in a doubly-linked list, removing an element is O(1), it's the finding of the element to be removed that's O(n). However, if you can somehow figure that out via other means (e.g. because of the way your algorithm is structured, you already have a reference to the element at that point), then removal is very efficient. That's why insertion-ordered maps have no asymptotic overhead compared to unordered maps: yes, you need a list to keep track of insertion order, but you never need to search in that list, because you can look the keys up in the map. Commented Nov 2, 2014 at 11:46
  • There’s usually just two operations: Retain an item and add it to the list (may happen multiple times), and release all items in the list and destroy the list. Commented Mar 3, 2020 at 9:12