예제 #1
0
        /// <summary>
        /// Performs a "union" of the two sets, where all the elements
        /// in both sets are present.  That is, the element is included if it is in either <c>a</c> or <c>b</c>.
        /// Neither this set nor the input set are modified during the operation.  The return value
        /// is a <c>Clone()</c> of this set with the extra elements added in.
        /// </summary>
        /// <param name="a">A collection of elements.</param>
        /// <returns>A new <c>Set</c> containing the union of this <c>Set</c> with the specified collection.
        /// Neither of the input objects is modified by the union.</returns>
        public Set Union(Set a)
        {
            Set resultSet = (Set)this.Clone();

            if (a != null)
            {
                resultSet.AddAll(a);
            }
            return(resultSet);
        }
예제 #2
0
        /// <summary>
        /// Adds all the elements in the specified collection to the set if they are not already present.
        /// </summary>
        /// <param name="c">A collection of objects to add to the set.</param>
        /// <returns><c>true</c> is the set changed as a result of this operation, <c>false</c> if not.</returns>
        public sealed override bool AddAll(ICollection c)
        {
            Set temp;

            lock (c.SyncRoot)
            {
                temp = new HybridSet(c);
            }

            lock (_syncRoot)
            {
                return(_basisSet.AddAll(temp));
            }
        }