예제 #1
0
        public void DeleteNElement(Node2 nodeToDelete)
        {
            // check for validity of the passed argument here
            if (nodeToDelete == null)
            {
                throw new IndexOutOfRangeException("Not valid element null");
            }

            if (nodeToDelete.next == null)
            {
                nodeToDelete.prev.next = null;
            }
            if (firstElement == nodeToDelete)
            {
                firstElement      = firstElement.next;
                firstElement.prev = null;
            }
            else
            {
                nodeToDelete.next.prev = nodeToDelete.prev;
                nodeToDelete.prev.next = nodeToDelete.next;
            }
        }