public override string ToString() { string res = "Count:" + count.ToString() + " "; LinkedNode <T> current = head; while (current != null) { res += current.data.ToString() + " "; current = current.next; } return(res); }
public T SearchAtKey(int key) { LinkedNode <T> current = head; while (current != null && current.Key != key) { current = current.next; } if (current == null) { return(default(T)); } else { return(current.data); } }
public void Add(LinkedNode <T> obj) { if (head == null) { head = obj; last = head; count++; return; } LinkedNode <T> current = head; while (current.next != null) { current = current.next; } current.next = obj; obj.pre = current; last = current.next; count++; }
public void Add(T obj) { if (head == null) { head = new LinkedNode <T>(obj); last = head; count++; return; } LinkedNode <T> current = head; while (current.next != null) { current = current.next; } current.next = new LinkedNode <T>(obj); current.next.pre = current; last = current.next; count++; }
public LinkedList(T obj) { head = new LinkedNode <T>(obj); count = 1; }