Пример #1
0
        /// <summary>
        /// Removes the <see cref="T:System.Collections.Generic.IList`1"></see> item at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the item to remove.</param>
        /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"></see> is read-only.</exception>
        /// <exception cref="T:System.ArgumentOutOfRangeException">index is not a valid index in the <see cref="T:System.Collections.Generic.IList`1"></see>.</exception>
        public void RemoveAt(int index)
        {
            DoublyLinkedListNode <T> nodeToRemove = _NodeAt(index);

            if (nodeToRemove != null)
            {
                DoublyLinkedListNode <T> nextNode     = nodeToRemove.Next;
                DoublyLinkedListNode <T> previousNode = nodeToRemove.Previous;
                if (previousNode != null)
                {
                    previousNode.Next = nextNode;
                }
                if (nextNode != null)
                {
                    nextNode.Previous = previousNode;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"></see>.
 /// </summary>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"></see> is read-only. </exception>
 public void Clear( )
 {
     _firstNode = null;
     _lastNode  = null;
 }