The doubly-linked queue should have "enqueue", "dequeue" and "peek" capabilities on either end. The methods we chose allow for adding and removing elements in both directions.
- public void addFirst(T x)
- Adds the element to the front of the deque
- public T removeFirst()
- Removes the element at the front of the deque and returns the removed element and throws error if empty
- public T peekFirst()
- Returns the element at the front of the deque
- public void addLast(T x)
- Adds the element to the end of the deque
- public T removeLast()
- Removes the element at the end of the deque and returns the removed element and throws error if empty
- public T peekLast()
- Returns the element at the end of the deque
- public boolean isEmpty()
- Returns true if the first element is null
- public int size()
- Returns number of elements present
Our team choose doubly-linked Node-based architecture for Deque because Deque is a double ended queue. The instance variables nextNode and prevNode and their methods from the doubly-linked nodes would be useful in adding, removing, and peeking from the front or end of the queue.