/// <summary> /// Removes all objects from the set. /// </summary> public sealed override void Clear() { lock (_syncRoot) { _basisSet.Clear(); } }
/// <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 if it exists in /// both sets. The <c>Intersect()</c> operation does not modify the input sets. It returns /// a <c>Clone()</c> of this set with the appropriate elements removed. /// </summary> /// <param name="a">A set of elements.</param> /// <returns>The intersection of this set with <c>a</c>.</returns> public Set Intersect(Set a) { Set resultSet = (Set)this.Clone(); if (a != null) { resultSet.RetainAll(a); } else { resultSet.Clear(); } return(resultSet); }
/// <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)); } }