Section 16.9 Class PriorityQueue and Interface Queue

• Interface Queue (p. 710) extends interface Collection and provides additional operations for inserting, removing and inspecting elements in a queue.

PriorityQueue (p. 710) implements interface Queue and orders elements by their natural ordering or by a Comparator object that’s supplied to the constructor.

PriorityQueue method offer (p. 710) inserts an element at the appropriate location based on priority order. Method poll (p. 710) removes the highest-priority element of the priority queue. Method peek (peek) gets a reference to the highest-priority element of the priority queue. Method clear (p. 710) removes all elements in the priority queue. Method size (p. 710) gets the number of ...

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.