Base types, Collections, Diagnostics, IO, RegEx…
Recently, I have heard a number of requests for the addition of a Set<T> class to the System.Collection.Generic namespace. Basic implementation of this class that implements only ICollection<T> would cover all the etremely vital operations a set should implement, but that would just be a weak List<T>. We want to cover more interesting functionality; at least Union, Intersect, Difference, Subset, and Disjoint.
While any person using set would expect these operations from a set class, there are many additional interesting options. Of them are symmetric difference, mapping/correspondence, predicates, min/max, and powersets. Does anyone out there need so much goodness, or is it a bit more than what you would need?
Other questions were more centered around the implementation. A set based on a hash would have extremely good performance with near-constant insert and remove, but would have a slow search time O(n). An ordered set, on the other hand, would probably take O(log n) for insert, search, and remove. This means that for most applications, the unordered list provides better results. Of course, the speed of these operations has serious impact on all of the other set operations. We may implement both.
So again, to solicit some more user comments (and thanks for the past ones!):
· Would the addition of a set class to the BCL make sense for the programs you are writing? Would you rather see something else implemented?
· How much functionality would you like to see in the class; do the members in the prototype below satisfy your needs, or are you looking for more (or less)?
· Do you see yourself using sets for ordered or unordered collections of values, or both?
Here's the source for a simple program that does some basic operation on odd and even sets of integers, it highlights the most basic operations one may want to do with a set:
Check it out and respond up here or send me an email at ArielW@microsoft.com!
Set of even integers under 10:
Set of odd integers under 10:
Do the even and odd sets intesect?
Even union odd integers:
Are even integers a subset of all integers?
Are all integers a subset of even integers?
Difference of All integers from Odd integers:
Set<T> UnionSet =
Set<T> IntersectSet =
Set<T> DifferenceSet =