public void append(Object value) { // TODO Node current = new Node(value); if (head == null) { head = current; } else { Node temp = head; while (temp.getNext() != null) { temp = temp.getNext(); } temp.setNext(current); } }
public void Print() { if (head == null) { Console.Write("List is empty"); return; } Node current = head; while (current != null) { Console.Write(current.getValue()); current = current.getNext(); } }
public void reverseInPlace() { // TODO if (head != null) { Node current = head; Node Next = current.getNext(); current.setNext(null); //Mark it as last node do { Node temp = Next.getNext(); Next.setNext(current); current = Next; Next = temp; } while (Next != null); head = current; } Print(); }
public void reverse() { // TODO if (head != null) { List <object> tempStore = new List <object>(); Node current = head; do { tempStore.Add(current.getValue()); current = current.getNext(); } while (current != null); tempStore.Reverse(); head = null; foreach (object o in tempStore) { this.append(o); } } Print(); }