Deque
Deque is an interface which is a double-ended queue. It extends the Queue interface with the methods that allow access to both ends of the queue to add, look at, and remove elements from both ends.
For the Queue interface we needed six methods. Dequeue having two manageable ends needs 12 methods. Instead of add we have addFirst and addLast. Similarly we can offerFirst, offerLast as well as peekFirst, peekLast and pollFirst, pollLast. For some reason the methods that implement the functionality of the element method on Queue are named getFirst and getLast.
Since this interface extends the Queue interface the methods defined there can also be used to access the head of the queue. In addition to these this interface also defines the methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access