|How come there's no such properties as "List|Dictionary.Capacity" - and, does anybody knows if inserting to last slot what's dotnet Collection behavior? Allocate 2xCapacity? In absence of MyDict.Capacity, how can I manipulate this?
Also, when you insert an element if Reference type into collection class, Collection class only stores a "Pointer" or "Reference", not a "Copy"
IDictionary SomeDict = new Dictionary<SomeClass, string>(MAXITEMS);<br />
SomeClass o = new SomeClass();<br />
o.a = -1;<br />
o.b = -1;<br />
o.c = -1;<br />
o.d = -1;<br />
SomeDict.Add(o, Guid.NewGuid().ToString());<br />
Observer this on debugger:
They'd give you same reference.
So, I'm not quite sure why I'd pick a LinkedList over a Dictionary - my guess is, Dictionary's Hash table in the back is still one contiguous block of memory, where as LinkedList is not (but also because it's slots of memory all over the place, access is slower?) But there's no MSDN doc or article which describes this (For example, LinkedList references to payload/elements are stored in usual "array" of reference? If so it too has allocation problem if you keep adding). So really is allocation the only concern?
Good reference but a bit unclear in some respect...[^]
modified on Monday, April 25, 2011 7:16 AM