/// <summary> /// Adds an object to the head of the list /// </summary> /// <param name="newNode"></param> public void addAtHead(object newNode) { Node temp = new Node(newNode); temp.next = head; head = temp; lenght++; }
/// <summary> /// Adds an object to tail of the list /// </summary> /// <param name="newNode">The object that will be inserted to the Tail of the LinkedList</param> public void addAtTail(object newNode) { Node temp = head; if (head == null) { head = new Node(newNode); } else { while ((temp.next) != null) { temp = temp.next; } temp.next = new Node(newNode); } lenght++; }