Java实现可泛型的Heap
可泛型的Heap,方便使用。
Heap接口:
?
? 最小推,MinHeap:
?
public class MaxHeap<T> extends AbstractHeap<T>{public MaxHeap(T[] elements){super(elements);}public MaxHeap(Comparator<T> com, T[] elements){super(com, elements);}/* * 注意两个参数比较的顺序 */@Overrideprotected int compare(int i, int j) throws NoComparableException{return super.compare(i, j);}@Overrideprotected int compare(T i, T j) throws NoComparableException{return super.compare(i, j);}}