This post only discusses scala.collection.mutable.LinkedList
. Other implementations are not the topic of this thread.
My question is: what is the use case of this class? I find it has the problems of both mutable and immutable type of structures while yielding the benefits of none. I say that because:
- the API looks to me as if it were an immutable API (
filter
,map
,drop
,take
etc all return a newLinkedList
instead of doing in-place modifications) - all the benefits of immutable linked list are, at least I guess, not present, ie maximum sharing between structures, since those are still mutable (through
var elem
andvar next
.
So basicly we have a linear access time, linear append time, linear space etc and nothing to show for it in space complexity or in ability to reason about code (except maybe the O(1) prepend but it's still the case with immutable lists).
Do I fail to see an important benefit of this type of structure? I'm looking for objective measures and/or use-cases appliable to this class.