示例#1
0
            /// <summary>
            /// Removes all the elements that aren't contained into the specified collection.
            /// </summary>
            /// <param name="collection">The collection used to verify the elements that will be retained.</param>
            /// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
            public virtual bool RetainAll(ICollection collection)
            {
                bool              result         = false;
                IEnumerator       tempEnumerator = this.GetEnumerator();
                CollectionSupport tempCollection = new CollectionSupport();

                tempCollection.AddAll(collection);
                while (tempEnumerator.MoveNext())
                {
                    if (!tempCollection.Contains(tempEnumerator.Current))
                    {
                        result = this.Remove(tempEnumerator.Current);

                        if (result == true)
                        {
                            tempEnumerator = this.GetEnumerator();
                        }
                    }
                }
                return(result);
            }
示例#2
0
			/// <summary>
			/// Removes all the elements that aren't contained into the specified collection.
			/// </summary>
			/// <param name="collection">The collection used to verify the elements that will be retained.</param>
			/// <returns>Returns true if all the elements were successfully removed. Otherwise returns false.</returns>
			public virtual bool RetainAll(System.Collections.ICollection collection)
			{
				bool result = false;
				System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
				CollectionSupport tempCollection = new CollectionSupport();
				tempCollection.AddAll(collection);
				while (tempEnumerator.MoveNext())
					if (!tempCollection.Contains(tempEnumerator.Current))
					{
						result = this.Remove(tempEnumerator.Current);
					
						if (result == true)
						{
							tempEnumerator = this.GetEnumerator();
						}
					}
				return result;
			}