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