示例#1
0
        public static DoublyLinkedListNode reverse(DoublyLinkedListNode llist)
        {
            if (llist == null)
            {
                return(llist);
            }

            DoublyLinkedListNode currentNode = llist;
            DoublyLinkedListNode newHead     = llist;

            while (currentNode != null)
            {
                DoublyLinkedListNode prev = currentNode.prev;
                currentNode.prev = currentNode.next;
                currentNode.next = prev;
                newHead          = currentNode;
                currentNode      = currentNode.prev;
            }

            return(newHead);
        }
示例#2
0
 public DoublyLinkedList()
 {
     this.head = null;
     this.tail = null;
 }
示例#3
0
 public DoublyLinkedListNode(int nodeData)
 {
     this.data = nodeData;
     this.next = null;
     this.prev = null;
 }