public PowerSet <T> Union(PowerSet <T> set2) { var union = new PowerSet <T>(Size() + set2.Size()); foreach (var value in slots) { union.Put(value); } foreach (var value2 in set2.slots) { union.Put(value2); } return(union); }
public PowerSet <T> Intersection(PowerSet <T> set2) { var intersection = new PowerSet <T>(Math.Max(Size(), set2.Size())); foreach (var value in base.slots) { if (set2.Contains(value)) { intersection.Put(value); } } return(intersection); }
public PowerSet <T> Difference(PowerSet <T> set2) { var difference = new PowerSet <T>(Math.Max(Size(), set2.Size())); foreach (var value in slots) { difference.Put(value); } foreach (var value2 in set2.slots) { difference.Remove(value2); } return(difference); }