/* * Override operator * to get intersection of two sets */ public static OrderedUniqueIntegersSet operator *(OrderedUniqueIntegersSet uiSet1, OrderedUniqueIntegersSet uiSet2) { OrderedUniqueIntegersSet uiSetIntersection = new OrderedUniqueIntegersSet(); foreach (int item in uiSet2.setOfItems) { if (uiSet1.Contains(item)) { uiSetIntersection.AddItem(item); } } return uiSetIntersection; }
/* * Override operator + to combine two sets */ public static OrderedUniqueIntegersSet operator +(OrderedUniqueIntegersSet uiSet1, OrderedUniqueIntegersSet uiSet2) { OrderedUniqueIntegersSet uiSetUnion = new OrderedUniqueIntegersSet(); foreach (int item in uiSet1.setOfItems) { uiSetUnion.AddItem(item); } foreach (int item in uiSet2.setOfItems) { uiSetUnion.AddItem(item); } return uiSetUnion; }