Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

priority queue is empty java

import java.util.PriorityQueue;

PriorityQueue<Integer> pq = new PriorityQueue<>();
pq.add(123);
pq.add(456);
pq.add(789);
System.out.println(pq);  // This will print [123, 456, 789]
pq.remove(); // This removes the head of the queue, i.e. 123
System.out.println(pq);  // This will print [456, 789]
pq.remove(789);
System.out.println(pq);  // This will print [456]
 
PREVIOUS NEXT
Tagged: #priority #queue #empty #java
ADD COMMENT
Topic
Name
9+2 =