You can find out some of the answers by looking at the source to Rotor.
However, there is a simple explanation.
The HybridDictionary uses a list for less than 10 items. It uses a
Hashtable for more than that.
There is an overhead, both in performance and in memory usage for a
hashtable. If you are using a whole lot of dictionaries, say in a
hierarchy, you may have a few that have lots of items, and many that have
only a few items. By dynamically adjusting the underlying type, you get
better performance and near optimal memory usage in this case.
If you were to use only Hashtable dictionaries, the memory usage would be
much higher, and the performance would be slightly slower.
If you were to use only list-based dictionaries, the memory usage would be
optimal, but the performance on searches on the larger nodes would be
terribly slow.
Again, the Rotor hashtable will shed a lot of light on this if you feel like
digging. Otherwise, just look up hash based searches in any college level
algorithms book.
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:OI**************@tk2msftngp13.phx.gbl...
Hi
Thanks. That was just what I was looking for.
I query your point regarding the performance of the Hashtable. Why would
MS then create the System.Collections.Specialized.HybridDictionary ?
Where can I find out how a HashTable works internaly?
Gary
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eZ*************@TK2MSFTNGP10.phx.gbl... Hi,
See the documentation and examples on the System.Collections.DictionaryBase class. It uses a HashTable internally, but is very convenient for
building strong-typed dictionaries.
On the other hand, Hashtable can be optimized for different amounts of
data stored so there's no reason to worry about its performance.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Gary van der Merwe" <ga*****@hotmail.com> wrote in message
news:eC*************@tk2msftngp13.phx.gbl... Hi
I want to write my own collection object. I want it to have the
following features.
1.. It must be strongly typed (to a Class that I have written).
2.. I should be able to add and remove items dynamically.
3.. It should have an indexer. This will have a string parameter.
The indexer should return the first item that's ID property is equal to
the parameter. These collections will generally contain less than 10
items, so I don't intend to use a HashTable.
I really don't know where to start. Dose any one know where I can find
a sample which dose something like this?
Gary