Engineering Full Stack Apps with Java and JavaScript
Deque stands for "double ended queue". Deque Interface extends Queue interface to provide a linear collection that supports element insertion and removal at both ends.
Deque interface supports capacity-restricted deques as well as those with no fixed size limit.
Deque interface defines methods to access the elements at both ends of the deque.
Methods are provided to insert, remove, and examine the element.
Each of the methods exists in two forms:
one throws an exception if the operation fails,
addFirst(e), removeFirst(), getFirst(), addLast(e), removeLast(), getLast().
the other returns a special value like null or false
offerFirst(e), pollFirst(), peekFirst(), offerLast(e), pollLast(), peekLast().
Deque can be used as a queue (FIFO behaviour) or stack (LIFO behaviour)
Preferred over legacy stack
This interface does not provide support for indexed access to elements.
The null is used as a special return value by various methods to indicated that the deque is empty.
Even if the implementation allows null, it is advised not to use nulls
Deque implementations generally inherit the identity-based versions of the equals and hashCode methods from class Object.
addFirst(e), removeFirst(), getFirst(), addLast(e), removeLast(), getLast().
offerFirst(e), pollFirst(), peekFirst(), offerLast(e), pollLast(), peekLast().
add(E e), contains(Object o), element(), descendingIterator(), pop(), push(E e).
removeFirstOccurrence(Object o), removeLastOccurrence(Object o).
BlockingDeqeue interface that extends from the Deque interface and BlockingQueue interface, belongs to java concurrency package and will be discussed when we discuss about java concurrency.