Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Lazy Developer

by 'Jimmy' Skowronski


Mysterious Generic TreeSet<T>

Just a few minutes ago, I was looking for something in the System. Collections.Generic using Reflector. I turned on visibility for Private members in options and then I saw something new, a TreeSet<T>. A few days before I was playing with tree structures, so this class turned my attention. After a short search on google, I found a kinf of documentation on Danish university webpage.

An implementation of Red-Black trees as an indexed, sorted collection with set semantics, cf. CLRS. TreeBag<T> for a version with bag semantics. TreeDictionary<K,V> for a sorted dictionary based on this tree implementation. The comparer (sorting order) may be either natural, because the item type is comparable (generic: or non-generic: System.IComparable) or it can be external and supplied by the user in the constructor.TODO: describe performance hereTODO: discuss persistence and its useful usage modes. Warn about the space leak possible with other usage modes.

What the Red-Black tree is? According to Wikipedia:

A red-black tree is a type of self-balancing binary search tree, a data structure used in computer science, typically used to implement associative arrays. The original structure was invented in 1972 by Rudolf Bayer who called them "symmetric binary B-trees", but acquired its modern name in a paper in 1978 by Leo J. Guibas and Robert Sedgewick. It is complex, but has good worst-case running time for its operations and is efficient in practice: it can search, insert, and delete in O(log n) time, where n is the number of elements in the tree.

Sounds great but … this is the internal class in System.Collections.Generic. Has anyone the slightest idea why is this class still kept in secret internal goods? That could be so useful. That is not fair.

I am going to cry alone.


Published Oct 13 2006, 02:20 PM by Jimmy
Filed under:

Comments

Michal Grzegorzewski said:

This class is used by System.Collections.Generic.SortedDictionary as an internal container (field named '_set' of this class).

If you are interested in good generics library, use powercollections from wintellectuals (http://www.wintellect.com/MemberOnly/PowerCollections.aspx) or C5 from IT University of Copenhagen (http://www.itu.dk/research/c5/)

# October 13, 2006 4:29 PM

Jimmy said:

Heh. C5 is the link I've found while I was looking for TreeSet<T> (look at the link in post). I assumed that this is some doc about class in System.Collections.Generic, not separate clas library. Exactly the same name.

Generally I'm not interested in good or bad generic libraries. I just wonder why Microsoft hide something that can be so useful.

# October 13, 2006 6:22 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jimmy

I currently work for MessageLabs, one of the best security companies in the world! I love the Microsoft technology stack and use it to make my company successful! Not only work is my life. I love mountains and climbing. That feeling when I'm on the wall and there is nothing around me, only void. When I can feel stone on my fingers, every tiny bit, when my fingers are going wet and chalk doesn't help, when my muscles and body are exhausted. Damn, I'd love it. Even more than programming. Check out Devlicio.us!

Our Sponsors

Red-Gate!