public void PushFront(T key) { var node = new DsLinkedListNode <T> { Key = key }; node.Next = _head; _head = node; if (_tail == null) { _tail = _head; } }
public void PushBack(T key) { var node = new DsLinkedListNode <T> { Key = key, Prev = _tail }; _tail = node; if (_head == null) { _head = _tail; } }
public T PopBack() { if (_tail == null) { throw new InvalidOperationException(); } var node = _tail; _tail = _tail.Prev; if (_tail == null) { _head = null; } else { _tail.Prev = null; } return(node.Key); }
public T PopFront() { if (_head == null) { throw new InvalidOperationException(); } var node = _head; _head = _head.Next; if (_head == null) { _tail = null; } else { _head.Prev = null; } return(node.Key); }