public void addToEnd(int data) { if (headNode == null) { headNode = new DoubleLinkNode(data); tailNode = headNode; } else { tailNode = headNode.addToEnd(data); } }
public void remove(int data) { if (next != null) { if (next.data == data) { next.next.prev = this; this.next = next.next; return; } next.remove(data); } }
public DoubleLinkNode addToEnd(int data) { if (next != null) { return(next.addToEnd(data)); } else { DoubleLinkNode temp = new DoubleLinkNode(data); next = temp; temp.prev = this; return(temp); } }
public void printReverse() { DoubleLinkNode current = tailNode; if (current == null) { Console.WriteLine("Empty list"); } else { do { Console.Write("|" + current.data + "|<=>"); current = current.prev; } while (current != null); } }
public DoublyLinkedList() { headNode = null; tailNode = null; }
public DoubleLinkNode(int data) { prev = null; next = null; this.data = data; }