Update: Despite what
the documentation says, this class is new to .NET 3.5, and is not present in the .NET 3.0 libraries.
Update: Fixed typo - HashSet does not allow duplicate members, just as you'd expect.
I was poking around the other day and I noticed System.Collections.Generics.HashSet<T>. Sure enough, it's a collection class with the semantics of a set: there are no duplicates no matter how many times you add an item to the set, it is unordered, and it supports intersection, union, and subset operations.
It's part of .NET 3.0 3.5, so it's been around for a little while not quite out yet. I doubt I'm the last (although I'm even more sure I'm not the first :) to hear of it, though. Go check it out, because a set is one of those data structures that gets used all the time. If you've ever instantiated a Dictionary<T, bool> just to keep track of if you've seen something, you know what I mean.
Thanks, CLR team!
Posted
Sep 25 2007, 09:35 AM
by
craig-andera