16.9 Class PriorityQueue and Interface Queue
Recall that a queue is a collection that represents a waiting line—typically, insertions are made at the back of a queue and deletions are made from the front. In Section 21.6, we’ll discuss and implement a queue data structure. In this section, we investigate Java’s Queue interface and PriorityQueue class from package java.util
. Interface Queue
extends interface Collection
and provides additional operations for inserting, removing and inspecting elements in a queue. PriorityQueue
, which implements the Queue
interface, orders elements by their natural ordering as specified by Comparable
elements’ compareTo
method or by a Comparator
object that’s supplied to the constructor.
Class PriorityQueue
provides ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.