views:

151

answers:

1

So, I was just digging around Reflector trying to find the implementation details of HashSet (out of sheer curiosity based on the answer to another question here) and noticed the following:

internal class TreeSet<T> : ICollection<T>, IEnumerable<T>, ICollection,
    IEnumerable, ISerializable, IDeserializationCallback

Without looking too deep into the details, it looks like a Self-Balancing Binary Search Tree.

My question is, is there anybody out there with the insight as to why this class is internal? Is it simply because the other collection types use it internally and hide the complexities of a BST from the general masses...or am I way off base?

+7  A: 

Exposing a type publicly involves a lot more work than only exposing it internally - it means you've got to be absolutely sure that you don't want to make significant changes to the API later, you've got to document it thoroughly etc.

I wouldn't be surprised to find a TreeSet<T> exposed in a future release, but it makes sense for MS to be cautious before making something public.

(I believe that SortedSet<T> in .NET 4 is basically a tree set, btw.)

Jon Skeet
You're right. SortedSet<T> Looks like a Red-Black BST. Thanks for the quick response.
Justin Niessner
Read the following article when you want to know how many Microsoft employees it actually takes to make this feature public: http://blogs.msdn.com/ericlippert/archive/2003/10/28/53298.aspx
Steven