0

This is a follow up to this question:

Pointer into Java LinkedList Node

C#'s LinkedList implementation is a list which is composed of LinkedListNodes, and such it enables to have a reference to a specific node AND can remove that node or add after/before that node in O(1).

Is there any Java list implementation which supports these actions with the same run time complexity? If not the ability to save the nodes themselves, then direct indexing is also a good option

Yonatan Nir
  • 8,303
  • 23
  • 80
  • 156
  • Is there even such data structure, for which both access and add/remove operations are all O(1)? I mean, you could try wrapping a `LinkedHashMap` into a `List` interface, but that only has a best-case O(1) complexity, I think. – M. Prokhorov Feb 11 '19 at 12:36
  • More on HashMap [in this question](https://stackoverflow.com/questions/4553624/hashmap-get-put-complexity). Linked hash map inherits it, allowing for simpler iteration impl due to setting which can allow to preserve insertion order. – M. Prokhorov Feb 11 '19 at 12:40

0 Answers0