/// <summary>
        /// Adds a node before a specified node in the <see cref="DoublyLinkedList{T}"/>.
        /// </summary>
        /// <remarks>
        /// This method is an O(1) operation.
        /// </remarks>
        /// <param name="node">The <see cref="DoublyLinkedListNode{T}"/> to add before.</param>
        /// <param name="value">The value of the node to add after the specified node.</param>
        public void AddBefore(DoublyLinkedListNode <T> node, T value)
        {
            ValidateAddArgs(node);

            DoublyLinkedListNode <T> n = new DoublyLinkedListNode <T>(value);

            // check if adding before _head node
            if (node == m_head)
            {
                n.Next          = m_head;
                m_head.Previous = n;
                m_head          = n;
            }
            else
            {
                n.Next             = node;
                node.Previous.Next = n;
                n.Previous         = node.Previous;
                node.Previous      = n;
            }

            Count++;
        }
        /// <summary>
        /// Adds a node after a specified node in the <see cref="DoublyLinkedList{T}"/>.
        /// </summary>
        /// <remarks>
        /// This is an O(1) operation.
        /// </remarks>
        /// <param name="node">The <see cref="DoublyLinkedListNode{T}"/> to add after.</param>
        /// <param name="value">The value of the node to add after the specified node.</param>
        public void AddAfter(DoublyLinkedListNode <T> node, T value)
        {
            ValidateAddArgs(node);

            DoublyLinkedListNode <T> n = new DoublyLinkedListNode <T>(value);

            // check if adding after _tail node
            if (node == m_tail)
            {
                n.Previous  = m_tail;
                m_tail.Next = n;
                m_tail      = n;
            }
            else
            {
                n.Next          = node.Next;
                n.Next.Previous = n;
                node.Next       = n;
                n.Previous      = node;
            }

            Count++;
        }
 /// <summary>
 /// Method that validates the state of the DoublyLinkedListCollection(Of T) as well as if the node passed in is null.
 /// This method is used by AddAfter, and AddBefore.
 /// </summary>
 /// <param name="node">Node to verify whether or not is null.</param>
 private void ValidateAddArgs(DoublyLinkedListNode <T> node)
 {
     Guard.InvalidOperation(IsEmpty(), Resources.DoublyLinkedListEmpty);
     Guard.ArgumentNull(node, "node");
 }
 /// <summary>
 /// Resets the <see cref="DoublyLinkedList{T}"/> back to its default state.
 /// </summary>
 public override void Clear()
 {
     m_head = null;
     m_tail = null;
     Count  = 0;
 }