#region Apache License 2.0 /* Nuclex .NET Framework Copyright (C) 2002-2024 Markus Ewald / Nuclex Development Labs Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #endregion // Apache License 2.0 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