Skip to Content
Java Projects - Second Edition
book

Java Projects - Second Edition

by Peter Verhas
August 2018
Intermediate to advanced
524 pages
14h 45m
English
Packt Publishing
Content preview from Java Projects - Second Edition

Deque

Deque is an interface that 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 need six methods. Dequeue, having two manageable ends, needs 12 methods. Instead of add(), we have addFirst() and addLast(). Similarly, we can use offerFirst() and offerLast(), peekFirst() and peekLast(), and pollFirst() and pollLast(). For some reason, the methods that implement the functionality of the element() method in the Queue interface are named getFirst() and getLast() in the Dequeue interface.

Since this interface extends the Queue interface, the methods defined there can also be used to access the head ...

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.
Start your free trial

You might also like

Java 11 Cookbook - Second Edition

Java 11 Cookbook - Second Edition

Nick Samoylov, Mohamed Sanaulla

Publisher Resources

ISBN: 9781789131895Supplemental Content