public DoublyLinkedList() { head = new DoublyLinkedNode(); head.value = 0; curr = head; middle = head; numNodesAdvanced = 0; }
@Override void add(int value) { this.value = value; curr.next = this; curr.next.prev = curr; curr = this; head.prev = curr; curr.next = head; }
void deleteTail() { curr.delete(); }
void deleteMiddleNode() { middle.delete(); }
void deleteHead() { head.delete(); }
void add(int val) { numNodesAdvanced++; DoublyLinkedNode node = new DoublyLinkedNode(); node.add(val); if (numNodesAdvanced % 2 == 0) middle = middle.next; }