To end with immutable trees, at least for now, we've implemented IDictionary<K, V>. It's named Map<K, V>. Functionally it looks very like SortedDictionary<K, V>. there are some differences, however:
IDictionary<K, V>
Map<K, V>
SortedDictionary<K, V>
Map
SortedDictionary
Sources are:
Update:
It was impossible to withstand temptation to commit some primitive performance comparision. Map outperforms SortedDictionary both in population and in access. this does not aggree with pure algorithm's theory, but there might be other unaccounted factors: memory consumption, quality of implementation, and so on.
Program.cs is updated with measurements.
Update 2:
More occurate tests show that for some key types Map's faster, for others SortedDictionary's faster. Usually Map's slower during population (mutable AVL tree navigator may fix this). the odd thing is that Map<string, int> is faster than SortedDictionary<string, int> both for allocaction and for access. See excel report.
Map<string, int>
SortedDictionary<string, int>
Update 3:
Interesing observation. The following table shows maximal and average tree heights for different node sizes in AVL and RB trees after a random population:
Here, according with theory, the height of AVL tree is shorter than the height of RB tree. But what is most interesting is that the depth of an "average node". This value describes a number of steps required to find a random key. RB tree is very close and often is better than AVL in this regard.
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u