using System; using System.Collections; using System.Collections.Generic; namespace Chernobyl.Collections.Generic { /// /// An implementation of that makes the /// creation of new instances easier. /// /// The type that is contained within the /// . public abstract class Collection : ICollection { /// /// Adds an item to the . /// /// The object to add to the . /// /// The is read-only. /// public void Add(T item) { Implementation.Add(item); } /// /// Removes all items from the . /// /// /// The is read-only. /// public void Clear() { Implementation.Clear(); } /// /// Determines whether the contains a /// specific value. /// /// The object to locate in the /// . /// /// true if is found in the /// ; otherwise, false. /// public bool Contains(T item) { return Implementation.Contains(item); } /// /// Copies the elements of the to an /// , starting at a particular /// index. /// /// The one-dimensional that is /// the destination of the elements copied from /// . The must have /// zero-based indexing. /// The zero-based index in /// at which copying begins. /// is /// null. /// /// is less than 0. /// /// is /// multidimensional, or is equal to or /// greater than the length of , or the number /// of elements in the source is greater /// than the available space from to the /// end of the destination , or type /// cannot be cast automatically to the type of the /// destination . public void CopyTo(T[] array, int arrayIndex) { Implementation.CopyTo(array, arrayIndex); } /// /// Gets the number of elements contained in the . /// /// /// The number of elements contained in the . /// public int Count { get { return Implementation.Count; } } /// /// Gets a value indicating whether the is /// read-only. /// /// true if the is read-only; /// otherwise, false. public bool IsReadOnly { get { return Implementation.IsReadOnly; } } /// /// Removes the first occurrence of a specific object from the /// . /// /// The object to remove from the /// . /// /// True if was successfully removed from the /// ; otherwise, false. This method also /// returns false if is not found in the /// original . /// /// /// The is read-only. /// public bool Remove(T item) { return Implementation.Remove(item); } /// /// Returns an enumerator that iterates through the collection. /// /// /// A that can be used to iterate through /// the collection. /// public IEnumerator GetEnumerator() { return Implementation.GetEnumerator(); } /// /// Returns an enumerator that iterates through a collection. /// /// /// An object that can be used to iterate /// through the collection. /// IEnumerator IEnumerable.GetEnumerator() { return Implementation.GetEnumerator(); } /// /// The implementation of this . /// protected abstract ICollection Implementation { get; } } }