#region CPL License /* Nuclex Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #endregion using System; using System.Collections.Generic; using System.Collections; namespace Nuclex.Support.Collections { partial class Deque { #region IEnumerable members /// Obtains a new enumerator for the contents of the deque /// The new enumerator IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(this); } #endregion #region IList Members /// Adds an item to the deque /// Item that will be added to the deque /// The index at which the new item was added int IList.Add(object value) { verifyCompatibleObject(value); AddLast((TItem)value); return this.count - 1; } /// Checks whether the deque contains the specified item /// Item the deque will be scanned for /// True if the deque contained the specified item bool IList.Contains(object value) { return isCompatibleObject(value) && Contains((TItem)value); } /// Determines the index of the item in the deque /// Item whose index will be determined /// The index of the specified item in the deque int IList.IndexOf(object value) { if(isCompatibleObject(value)) { return IndexOf((TItem)value); } else { return -1; } } /// Inserts an item into the deque at the specified location /// Index at which the item will be inserted /// Item that will be inserted void IList.Insert(int index, object value) { verifyCompatibleObject(value); Insert(index, (TItem)value); } /// Whether the deque has a fixed size bool IList.IsFixedSize { get { return false; } } /// Whether the deque is read-only bool IList.IsReadOnly { get { return false; } } /// Removes the specified item from the deque /// Item that will be removed from the deque void IList.Remove(object value) { if(isCompatibleObject(value)) { Remove((TItem)value); } } /// Accesses an item in the deque by its index /// Index of the item that will be accessed /// The item at the specified index object IList.this[int index] { get { return this[index]; } set { verifyCompatibleObject(value); this[index] = (TItem)value; } } #endregion #region ICollection Members /// Adds an item into the deque /// Item that will be added to the deque void ICollection.Add(TItem item) { AddLast(item); } /// Whether the collection is read-only bool ICollection.IsReadOnly { get { return false; } } #endregion #region ICollection Members /// Copies the contents of the deque into an array /// Array the contents of the deque will be copied into /// Index at which writing into the array will begin void ICollection.CopyTo(Array array, int index) { if(!(array is TItem[])) { throw new ArgumentException("Incompatible array type", "array"); } CopyTo((TItem[])array, index); } /// Whether the deque is thread-synchronized bool ICollection.IsSynchronized { get { return false; } } /// Synchronization root of the instance object ICollection.SyncRoot { get { return this; } } #endregion } } // namespace Nuclex.Support.Collections