A double ended queue is a combination of a stack and a queue. The idea is that you are allowed to insert and remove elements at both ends of the queue. If you remove elements from the side you have inserted, it will behave like a stack. On the other hand, if you insert and remove on opposite ends, it will behave like a queue. You can mix these operations and use them in any order you like. The following figure shows a few operations to clarify this idea:
A double ended queue has the following operations all with a complexity of O(n):
A double ended queue will be represented by the following interface:
public interface DoubleEndedQueue<E> extends Stack<E> { void inject(E value); E eject(); E peekLast(...