Why did they name PriorityQueue if you can’t insertWithPriority? It seems very similar to a heap. Are there any differences? If no difference, then why was it named PriorityQueue and not Heap?
Why did they name PriorityQueue if you can’t insertWithPriority ? It seems very similar
Share
Add() works like an insertWithPriority.
You can define priority for the type that you want using the constructor:
look under https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/PriorityQueue.html
The order the Comparator gives will represent the priority in the queue.