Exemplo n.º 1
0
        public void AddLast(T value)
        {
            var node = new DoubleLinkedNode <T>(value);

            if (First == null)
            {
                First = node;
            }
            else
            {
                Last.Next = node;
                node.Prev = Last;
            }
            Last = node;
            count++;
        }
Exemplo n.º 2
0
        public void AddFirst(T value)
        {
            DoubleLinkedNode <T> node = new DoubleLinkedNode <T>(value);
            DoubleLinkedNode <T> temp = First;

            node.Next = temp;
            First     = node;
            if (count == 0)
            {
                Last = First;
            }
            else
            {
                temp.Prev = node;
            }
            count++;
        }
Exemplo n.º 3
0
        public void Reverse()
        {
            DoubleLinkedNode <T> temp    = null;
            DoubleLinkedNode <T> current = First;

            while (current != null)
            {
                temp         = current.Prev;
                current.Prev = current.Next;
                current.Next = temp;
                current      = current.Prev;
            }
            if (temp != null)
            {
                First = temp.Prev;
            }
        }