예제 #1
0
        /// <summary>
        /// Retains only the elements in this set that are contained in the specified collection.
        /// </summary>
        /// <param name="c">Collection that defines the set of elements to be retained.</param>
        /// <returns><c>true</c> if this set changed as a result of this operation.</returns>
        public sealed override bool RetainAll(ICollection c)
        {
            Set temp;

            lock (c.SyncRoot)
            {
                temp = new HybridSet(c);
            }
            lock (_syncRoot)
            {
                return(_basisSet.RetainAll(temp));
            }
        }
예제 #2
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 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);
        }