示例#1
0
            /// <summary>
            /// Returns a new list containing a portion of the current list between a specified range.
            /// </summary>
            /// <param name="startIndex">The start index of the range.</param>
            /// <param name="endIndex">The end index of the range.</param>
            /// <returns>A ListCollectionSupport instance containing the specified elements.</returns>
            public virtual ListCollectionSupport SubList(int startIndex, int endIndex)
            {
                int                   index          = 0;
                IEnumerator           tempEnumerator = this.GetEnumerator();
                ListCollectionSupport result         = new ListCollectionSupport();

                for (index = startIndex; index < endIndex; index++)
                {
                    result.Add(this[index]);
                }
                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(ICollection collection)
            {
                bool                  result         = false;
                IEnumerator           tempEnumerator = this.GetEnumerator();
                ListCollectionSupport tempCollection = new ListCollectionSupport(collection);

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

                        if (result == true)
                        {
                            tempEnumerator = this.GetEnumerator();
                        }
                    }
                }
                return(result);
            }
示例#3
0
			/// <summary>
			/// Returns a new list containing a portion of the current list between a specified range. 
			/// </summary>
			/// <param name="startIndex">The start index of the range.</param>
			/// <param name="endIndex">The end index of the range.</param>
			/// <returns>A ListCollectionSupport instance containing the specified elements.</returns>
			public virtual ListCollectionSupport SubList(int startIndex, int endIndex)
			{
				int index = 0;
				System.Collections.IEnumerator tempEnumerator = this.GetEnumerator();
				ListCollectionSupport result = new ListCollectionSupport();
				for(index = startIndex; index < endIndex; index++)
					result.Add(this[index]);
				return (ListCollectionSupport)result;
			}
示例#4
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();
				ListCollectionSupport tempCollection = new ListCollectionSupport(collection);
				while (tempEnumerator.MoveNext())
					if (!tempCollection.Contains(tempEnumerator.Current))
					{
						result = this.RemoveElement(tempEnumerator.Current);
					
						if (result == true)
						{
							tempEnumerator = this.GetEnumerator();
						}
					}
				return result;
			}