public void Append(int value) { DoubleNode newNode = new(value) { previous = this.tail }; this.tail.next = newNode; this.tail = newNode; this.length++; }
public void Prepend(int value) { DoubleNode newNode = new(value) { next = this.head }; this.head.previous = newNode; this.head = newNode; this.length++; }
public DoubleNode TraverseNode(int index) { int counter = 0; index = WrapIndex(index); DoubleNode currentNode = head; while (counter != index) { currentNode = currentNode.next; counter++; } return(currentNode); }
public void PrintList() { if (this.head == null) { return; } DoubleNode current = this.head; while (current != null) { Console.Write("-->" + current.value); current = current.next; } Console.ReadLine(); }
public DoubleLinkedList(int value) { this.head = new DoubleNode(value); this.tail = this.head; this.length = 1; }
public DoubleNode(int value) { this.value = value; this.next = null; this.previous = null; }