??java???????????????????????
???????????? ???????[ 2013/2/6 9:48:31 ] ????????
????????????У??????????????????????????????????и????????????????????????о??и?????????????????????????????????
package priorityQueue;
import heap.Heap;
public class MyPriorityQueue {
private Heap heap = new Heap();
public void enqueue(Object newObject) {
heap.add(newObject);
}
public Object dequeue() {
return heap.remove();
}
public int getSize() {
return heap.getSize();
}
}
??????????
package priorityQueue;
public class TestPriorityQueue {
public static void main(String[] args) {
Patient patient1 = new Patient("john"?? 2);
Patient patient2 = new Patient("slmile"?? 0);
Patient patient3 = new Patient("dohn"?? 5);
Patient patient4 = new Patient("jack"?? 3);
Patient patient5 = new Patient("sen"?? 7);
MyPriorityQueue priorityQueue = new MyPriorityQueue();
priorityQueue.enqueue(patient1);
priorityQueue.enqueue(patient2);
priorityQueue.enqueue(patient3);
priorityQueue.enqueue(patient4);
priorityQueue.enqueue(patient5);
while (priorityQueue.getSize() > 0) {
System.out.println(priorityQueue.dequeue() + " ");
}
}
}
class Patient implements Comparable {
private String name;
private int priority;
public Patient(String name?? int priority) {
this.name = name;
this.priority = priority;
}
public String toString() {
return name + "(priority: " + priority + ")";
}
public int compareTo(Object o) {
return this.priority - ((Patient) o).priority;
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11