Vote For Generic Set Class
From time to time, I find myself in a situation where I need a class that mimics the behavior of a mathematical set:
- Elements are unordered
- An element can only appear once
- Sets can interact via Union, Intersect, Difference, IsSubset, IsSuperset, etc.
It's not that writing such a class is particularly hard to do, and in fact, I've done it several times; I just wish that there was a Set<T> class in the Base Class Library (BCL). For that reason, I have employed our own formal feedback channel to suggest this for a future version of the .NET framework. If you also think that this would be a good idea, I suggest that you go vote for Set<T> (you'll need to log in before you can vote). The more votes this suggestion gets, the more likely it is to be implemented.
Before anyone points me to some of the publicly available implementations, I might as well point out that the purpose of this suggestion is to include what I think would be a nice utility class in a readily available place (the BCL). I'm aware that free implementations exist (such as in Wintellect's Power Collections), but typically, I don't want to have to import, manage and deploy a complete third-party library just to implement a bit of logic, and I usually end up using some other collection and tweaking my logic a bit. It's just that, every time I do this, I wish I had a Set<T>.
Update: As was pointed out to me in a comment, there will be a HashSet<T> in Orcas, so voting on Set<T> isn't nessary. It's already coming, it just has a different name :)
Comments
Anonymous
February 08, 2007
Did you see this ? http://blogs.msdn.com/bclteam/archive/2006/11/09/introducing-hashset-t-kim-hamilton.aspxAnonymous
February 09, 2007
Hi Mike No, I hadn't seen that - that's very good news, although it makes my feedback voting campaign moot :) When I post things like this, I always first do a Live Search to see if someone has already given a satisfactory treatment of the subject. In this case I didn't find anything, because the final name will be HashSet<T> and not Set<T>. In any case, HashSet<T> looks like just the class I've been missing all these years :) Thanks for pointing that out!Anonymous
February 09, 2007
it would be nice to have a Graph library (similar to Boost in C++)..Anonymous
February 09, 2007
The primary purpose to include such a class to BCL is not convenient location, but to reduce overal memory cost for the whole Windows OS. BCL libraries are loaded once per each library for the whole running OS instance. Libraries like Winternal's PowerCollections will likely tax memory and hit the whole hierarchy of caches for every single process using it. So, the most effective way to push the class there is to measure/predict it's possible usage. The more likely it to be reused often, the more likely it to be in BCL.Anonymous
February 09, 2007
Hi SBC Thank you for your comment. Unfortunately, I'm not familiar with Boost, since I don't use C++, so I don't know what you are looking for. However, if you wish to suggest such a product feature, you can employ the same feedback mechanism that I used: Go to the Visual Studio and .NET Framework feedback site at http://connect.microsoft.com/VisualStudio/Feedback and post a new suggestion. Anyone with a Live ID can do this.Anonymous
February 09, 2007
Hi Mihailik Thank you for your comment. It's a good point, but sometimes managability and deployment can be important as well. When I create applications, the decision to use a third-party library must be resolved based on several factors, including: How much will it boost productivity?What is the managability cost of using the library?When considering such a thing as Set<T>, I've never felt that the productivity boost was worth the managability cost; i.e. even though it would be nice to have, I can get by without it, so I don't really want to have to manage and deploy yet another assembly. That's why I'd like this class to be in the BCL, and as you may have noticed from some of the other comments to this post, the BCL team agree with me that such a thing would be beneficial to put in the BCL :)Anonymous
February 09, 2007
I missed that point about HashSet<T>, sorry :-) So it's great, we have the useful class in BCL. Thank you to pointing to this!