A
Altramagnus
Why doesn't .NET framework Collections does not have linked list and
treemap?
treemap?
treemap?
Marc Scheuner said:See this comment by Julian Bucknall:
http://www.boyet.com/FixedArticles/EZDSL.html
"To be honest, it needs rewriting completely. When I wrote EZDSL, I
used the best knowledge I had at the time, but it's starting to look
long in the tooth.
* The linked lists won't get converted: using an ArrayList or a TList
is a much better and more efficient solution."
Just use an ArrayList in C# - it should give you all you need, really.
Jon Skeet said:Well, unless you need a list which is efficient for
insertions/removals/enumeration, but don't need fast random access. The
times when it's worth using a linked list are few, IME, but they do
exist.
Niki Estner said:Really? If I remove an element of a list and throw it away, the GC will have
to move (in average) half of the list's elements around when compacting the
heap. So where's the advantage in comparison to the ArrayList?
Next: Insertion; Well, it is pretty fast to insert an element in the middle
of a linked list, but then you have a GC gen 0 object with references to and
from gen 1/2 objects, i.e. the GC will always have to do scan through all
generations. I'd guess the ArrayList beats the linked list here, too.
Last point: enumeration. Let's say I want to call a method on all objects in
an ArrayList; I need to resolve one pointer per object (the one pointing to
the object), and due to the memory layout of the array, the number of cache
misses is quite low. For enumerating a linked list, on the other hand, I
have to resolve two pointers (one to the object, one to the next list item)
and the chances for cache misses is quite high (at least if items are
inserted in the middle of the list - and that was the whole reason to use
the list at all).