コード例 #1
0
 /*
  * 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;
 }
コード例 #2
0
        /*
         * 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;
        }