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

            lock (c.SyncRoot)
            {
                temp = new HybridSet(c);
            }
            lock (_mSyncRoot)
            {
                return(_mBasisSet.RetainAll(temp));
            }
        }
Example #2
0
        /// <summary>
        /// Adds all the elements in the specified collection to the set if
        /// they are not already present.
        /// </summary>
        /// <param name="collection">A collection of objects to add to the set.</param>
        /// <returns>
        /// <see langword="true"/> is the set changed as a result of this
        /// operation.
        /// </returns>
        public override sealed bool AddAll(ICollection collection)
        {
            if (collection == null)
            {
                return(false);
            }
            Set temp;

            lock (collection.SyncRoot)
            {
                temp = new HybridSet(collection);
            }
            lock (_mSyncRoot)
            {
                return(_mBasisSet.AddAll(temp));
            }
        }
        /// <summary>
        /// Retains only the elements in this set that are contained in the
        /// specified collection.
        /// </summary>
        /// <param name="collection">
        /// The collection that defines the set of elements to be retained.
        /// </param>
        /// <returns>
        /// <see langword="true"/> if this set changed as a result of this
        /// operation.
        /// </returns>
        public override bool RetainAll(ICollection collection)
        {
            //Put data from C into a set so we can use the Contains() method.
            Set cSet = new HybridSet(collection);

            //We are going to build a set of elements to remove.
            Set removeSet = new HybridSet();

            foreach (object o in this)
            {
                //If C does not contain O, then we need to remove O from our
                //set.  We can't do this while iterating through our set, so
                //we put it into RemoveSet for later.
                if (!cSet.Contains(o))
                {
                    removeSet.Add(o);
                }
            }
            return(this.RemoveAll(removeSet));
        }
Example #4
0
 public override void SetUp () 
 {
     Set = new HybridSet ();
     SetForSetOps = new HybridSet ();
 }
Example #5
0
 public override void SetUp()
 {
     Set          = new HybridSet();
     SetForSetOps = new HybridSet();
 }
        /// <summary>
        /// Gets all of the interfaces that the 
        /// supplied <see cref="System.Type"/> implements.
        /// </summary>
        /// <remarks>
        /// This includes interfaces implemented by any superclasses.
        /// </remarks>
        /// <param name="type">
        /// The type to analyse for interfaces.
        /// </param>
        /// <returns>
        /// All of the interfaces that the supplied <see cref="System.Type"/> implements.
        /// </returns>
        public static Type[] GetAllInterfacesFromType(Type type)
        {
            AssertUtils.ArgumentNotNull(type, "type");
            ISet interfaces = new HybridSet();
            do
            {
                Type[] ifcs = type.GetInterfaces();
                foreach (Type ifc in ifcs)
                {
                    interfaces.Add(ifc);
                }
                type = type.BaseType;
            } while (type != null);

            if (interfaces.Count > 0)
            {
                Type[] types = new Type[interfaces.Count];
                interfaces.CopyTo(types, 0);
                return types;
            }
            return Type.EmptyTypes;
        }