Set of Sets

Apr 13, 2009 at 8:15 PM
I am having a bit of trouble understanding how I could efficiently implement a set of sets. I try the following:


Set<string> set1 = new Set<string>(new string[] { "A", "B", "C" });



Set<string> set2 = new Set<string>(new string[] { "C", "B", "A" });



Set<string> set3 = new Set<string>(new string[] { "B", "A", "C" });



Set<string> set4 = new Set<string>(new string[] { "A", "B", "D" });



Set<Set<string>> set5 = new Set<Set<string>>();







Assert.AreEqual(2, set5.Count, "set of sets should only contain two items");

Since sets 1 - 3 are the same I would expect set5 to only contain two items since the two adds after set2 and set3 are essentially adding the same set. Right? If this doesn't work I suspect that set4.Contains(setx) would not work also if setx is also a set of the same components as 1-3.


Thank you.