import java.util.PriorityQueue;
import java.util.Iterator;
public class MyClass {
public static void main(String args[]) {
PriorityQueue<Integer> pq = new PriorityQueue<Integer>(6, (a,b) -> a - b);
pq.add(7686);
pq.add(98763);
pq.add(234);
pq.add(120);
pq.add(9);
pq.add(98);
Iterator<Integer> itr = pq.iterator();
while(itr.hasNext()) {
System.out.print(itr.next() + " ");
}
System.out.println("\nsize: " + pq.size());
while (!pq.isEmpty()) {
System.out.print(pq.poll() + " ");
}
System.out.println("\nsize: " + pq.size());
}
}
/*
run:
9 120 98 98763 234 7686
size: 6
9 98 120 234 7686 98763
size: 0
*/