1 /**
2 This program demonstrates the use of a heap as a priority queue.
3 */
4 public class HeapDemo
5 {
6 public static void main(String[] args)
7 {
8 MinHeap q = new MinHeap();
9 q.add(new WorkOrder(3, "Shampoo carpets"));
10 q.add(new WorkOrder(7, "Empty trash"));
11 q.add(new WorkOrder(8, "Water plants"));
12 q.add(new WorkOrder(10, "Remove pencil sharpener shavings"));
13 q.add(new WorkOrder(6, "Replace light bulb"));
14 q.add(new WorkOrder(1, "Fix broken sink"));
15 q.add(new WorkOrder(9, "Clean coffee maker"));
16 q.add(new WorkOrder(2, "Order cleaning supplies"));
17
18 while (q.size() > 0)
19 System.out.println(q.remove());
20 }
21 }