/**
* 优先级队列
*
* @author wind
*/
public class PriorityQueueDemo {
public static void main(String[] args) {
// 倒序
PriorityQueue<Integer> queue = new PriorityQueue<>((o1, o2) -> o2 - o1);
queue.add(2);
queue.add(1);
queue.add(4);
queue.add(3);
while (! queue.isEmpty()) {
System.out.println(queue.poll());;
}
}
}