示例#1
0
        /// <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);
                }
            }
        }
示例#2
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
 /// <returns>
 ///   <see langword="true" /> if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, <see langword="false" />.
 /// </returns>
 public bool Contains(T item)
 => set.Contains(item);