# Java构造大顶堆、小顶堆
// 构造小顶堆:
PriorityQueue small_heap=new PriorityQueue<>();
// 构造大顶堆:
PriorityQueue big_heap
=new PriorityQueue<>(Collections.reverseOrder());
//比较自定义类型对象大小
PriorityQueue<Integer>bigHeap=new PriorityQueue<>(new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o2-o1;
}
});
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12