Question: Revise MyPriorityQueue in Listing 24.9, using a generic parameter for comparing objects. Define a new constructor with a Comparator as its argument as follows:PriorityQueue(Comparator comparator)
Revise MyPriorityQueue in Listing 24.9, using a generic parameter for comparing objects. Define a new constructor with a Comparator as its argument as follows:PriorityQueue(Comparator comparator)
Listing

1 public class MyPriorityQueue { private Heap heap = new Heap (); 3 4 5 public void enqueue(E newObject) { heap.add(newObject); public E dequeue () { return heap.remove (); 10 11 12 13 public int getSize() { return heap.getSize(); 14 15 }
Step by Step Solution
3.51 Rating (161 Votes )
There are 3 Steps involved in it
PriorityQueue Program Plan Define the class Prior ityQueue Define the GeometricObj ect to define the ... View full answer
Get step-by-step solutions from verified subject matter experts
