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>>();

 

set5.Add(set1);

set5.Add(set2);

set5.Add(set3);

set5.Add(set4);

 

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.

Ideas?

Thank you.

Kevin