3 ms·
> if list elements are stored contiguously, is there any advantage to using a linked list Storing them contiguously probably implies that you consider "freed"
by matvore 6y ago
> if list elements are stored contiguously, is there any advantage to using a linked list
Storing them contiguously probably implies that you consider "freed" space in the middle to also be part of the contiguous area. Otherwise you can't remove in O(1) time.
It is straightforward to maintain a list of freed nodes which you can add back later.
If you don't mind not being able to remove in O(1) time, you still have the advantage of passing the handi-capped (contiguous) linked list to interfaces that expect a linked list, but still get the cache locality of a plain vector.