Beispiel #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);
        }
Beispiel #2
0
 public DoublyLinkedList()
 {
     this.head = null;
     this.tail = null;
 }
Beispiel #3
0
 public DoublyLinkedListNode(int nodeData)
 {
     this.data = nodeData;
     this.next = null;
     this.prev = null;
 }