Exemplo n.º 1
0
        //insert new DoubleLinkedListNode with given value at the end of the list
        public DoubleLinkedList <T> AddLast(T value)
        {
            DoubleLinkedListNode <T> node = new DoubleLinkedListNode <T>(value);

            if (Count > 0)
            {
                Last.Next = node;
                node.Prev = Last;
            }
            else
            {
                First = node;
            }
            Last = node;
            Count++;
            return(this);
        }
Exemplo n.º 2
0
        //insert new DoubleLinkedListNode with given value at the start of the list
        public DoubleLinkedList <T> AddFirst(T value)
        {
            DoubleLinkedListNode <T> node = new DoubleLinkedListNode <T>(value);
            DoubleLinkedListNode <T> temp = First;

            node.Next = temp;
            First     = node;
            if (Count > 0)
            {
                temp.Prev = node;
            }
            else
            {
                Last = First;
            }
            Count++;
            return(this);
        }