标签:优先 todo 基于 max ble nts bool generate front
优先队列基于最大堆的实现:
package queue;
import binaryHeap.MaxHeap;
/**
* 基于最大堆的优先队列
* @author DELL
*
*/
public class PriorityQueue<E extends Comparable<E>> implements Queue<E>{
private MaxHeap<E> maxHeap;
public PriorityQueue(){
maxHeap = new MaxHeap<>();
}
@Override
public void enqueue(E e) {
maxHeap.add(e);
}
@Override
public E dequeue() {
return maxHeap.extractMax();
}
@Override
public E getFront() {
return maxHeap.findMax();
}
@Override
public int getSize() {
return maxHeap.getSize();
}
@Override
public boolean isEmpty() {
// TODO Auto-generated method stub
return maxHeap.isEmpty();
}
}
标签:优先 todo 基于 max ble nts bool generate front
原文地址:https://www.cnblogs.com/tc971121/p/10583824.html