public DoubleLinkedListNode <T> AddLast(T value) { var node = new DoubleLinkedListNode <T>(value); if (Head == null) { Head = node; Tail = Head; } else { node.Previous = Tail; Tail.Next = node; Tail = node; } return(node); }
public void Remove(DoubleLinkedListNode <T> node) { if (Head == node) { if (node.Next != null) { node.Next.Previous = null; Head = node.Next; } else { Head = null; Tail = null; } return; } var previous = node.Previous; previous.Next = node.Next; }
public void Clear() { Head = null; Tail = null; }