public class MaxHeap<E> extends Object
| Constructor and Description |
|---|
MaxHeap(int maxSize,
Comparator<E> comparator)
构造最大堆
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
添加一个元素
|
MaxHeap<E> |
addAll(Collection<E> collection)
添加许多元素
|
List<E> |
toList()
转为有序列表,自毁性操作
|
public MaxHeap(int maxSize,
Comparator<E> comparator)
maxSize - 保留多少个元素comparator - 比较器,生成最大堆使用o1-o2,生成最小堆使用o2-o1,并修改 e.compareTo(peek) 比较规则Copyright © 2014–2018 码农场. All rights reserved.