Example #1
0
        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);
        }
Example #2
0
        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;
        }
Example #3
0
 public void Clear()
 {
     Head = null;
     Tail = null;
 }