/// <summary> /// Determines whether the current set is a superset of a specified collection. /// </summary> /// <param name="other">The collection to compare to the current set.</param> /// <returns> /// <see langword="true" /> if the current set is a superset of <paramref name="other" />; otherwise, <see langword="false" />. /// </returns> public bool IsSupersetOf(IEnumerable <T> other) { InputIEnumerableValidator(other); var otherSet = new BinarySearchTree.BinarySearchTree <T>(other); foreach (var item in otherSet.PreOrder()) { if (!set.Contains(item)) { return(false); } } return(true); }
/// <summary> /// Modifies the current set so that it contains only elements that are also in a specified collection. /// </summary> /// <param name="other">The collection to compare to the current set.</param> public void IntersectWith(IEnumerable <T> other) { InputIEnumerableValidator(other); var otherSet = new BinarySearchTree.BinarySearchTree <T>(other); var tempSet = new BinarySearchTree.BinarySearchTree <T>(set.PreOrder()); set = new BinarySearchTree.BinarySearchTree <T>(); foreach (var item in otherSet.PreOrder()) { if (tempSet.Contains(item)) { set.Add(item); } } }