Beispiel #1
0
        public T PopBack()
        {
            if (Empty)
            {
                throw new Exception("DEQUE empty.");
            }

            last.Previous.Next = null;

            DoublyLinkedElement <T> temp = last;

            last = last.Previous;
            return(temp.Valor);
        }
Beispiel #2
0
        public T PopFront()
        {
            if (Empty)
            {
                throw new Exception("DEQUE empty.");
            }

            first.Next.Previous = null;

            DoublyLinkedElement <T> temp = last;

            first = first.Next;
            return(temp.Valor);
        }
Beispiel #3
0
        public void PushFront(T valor)
        {
            if (valor == null)
            {
                throw new Exception("Invalid value: null");
            }
            DoublyLinkedElement <T> element = new DoublyLinkedElement <T>(valor);

            if (Empty)
            {
                last = element;
            }
            else
            {
                first.Previous = element;
                element.Next   = first;
            }

            first = element;
        }