public void Print() { DoubleNode current = head; while (current != null) { Console.WriteLine(current.data); current = current.next; } }
public int Count() { int i = 0; DoubleNode current = head; while (current != null) { i++; current = current.next; } return(i); }
public DoubleNode Find(string search) { if (head == null) { Console.WriteLine("List is empty"); return(null); } else { DoubleNode current = head; while (current != null) { if (current.data.ToString() == search) { return(current); } current = current.next; } return(null); } }
public void Delete(string nodeName) { var node = Find(nodeName); DoubleNode previous = null, current = head; while (current != null) { if (current == node) { head = current.next; } if (current.next == node) { previous = current; previous.next = current.next.next; current.next.previous = current; } current = current.next; } }
public string[] Values() { int i = 0; int count = Count(); DoubleNode current = head; string[] result = new string[count]; while (current != null) { result[i] = current.data; if (current.next == null) { break; } else { current = current.next; } i++; } return(result); }