Assume that I am using the PriorityQueue class from Java.util. I want to remove the largest number from the PriorityQueue pq, which we assume is at the head of the queue.
Will the following work?
// 1
int head = pq.peek();
pq.dequeue(head);
// 2
int head = pq.dequeue(pq.peek());
Would this work the same for non-primitives as well?