public DoublyLinkedListNode <T> AddLast(T value) { DoublyLinkedListNode <T> node = new DoublyLinkedListNode <T>(value); if (IsEmpty) { First = node; } else { node.Previous = Last; Last.Next = node; } Last = node; Count++; return(node); }
public void AddLast(DoublyLinkedListNode <T> node) { if (Count == 0) { Head = node; } else { Tail.Next = node; // Before: Head -> 3 <-> 5 -> null // After: Head -> 3 <-> 5 <-> 7 -> null // 7.Previous = 5 node.Previous = Tail; } Tail = node; Count++; }
public void Clear() { First = null; Last = null; Count = 0; }