Exemplo n.º 1
0
 /// <summary>
 /// Performs an "intersection" of the two sets, where only the elements
 /// that are present in both sets remain.  That is, the element is included only if it exists in
 /// both <c>a</c> and <c>b</c>.  Neither input object is modified by the operation.
 /// The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the
 /// elements from the intersect operation.
 /// </summary>
 /// <param name="a">A set of elements.</param>
 /// <param name="b">A set of elements.</param>
 /// <returns>The intersection of the two input sets.  <c>null</c> if both sets are <c>null</c>.</returns>
 public static Set Intersect(Set a, Set b)
 {
     if (a == null && b == null)
     {
         return(null);
     }
     else if (a == null)
     {
         Set resultSet = (Set)((Set)b).Clone();
         resultSet.Clear();
         return(resultSet);
     }
     else if (b == null)
     {
         Set resultSet = (Set)((Set)a).Clone();
         resultSet.Clear();
         return(resultSet);
     }
     else
     {
         return(a.Intersect(b));
     }
 }