/// <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); }
/// <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); }
/// <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; }
/// <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; }