Get and remove for LinkedList?

Hello everybody,

I noticed that LinkedList does not have a get or remove functionality. This seems like essential behavior, is there a technical or other reason?

get on a linked list is O(n) so it would be the same as .iter().nth(index)

And there is a remove function, it's just unstable.

Thanks!

Linked list is pretty abandoned because it's the worst collection and rarely what you want. In the cases where linked lists are the best tool for the job, you very rarely want a collection but instead want intrusive pointers.

5 Likes

Note that there are intrusive collections in the crate intrusive-collections, including a linked list. It requires modifying the type of the element to add a LinkedListLink field to it.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.