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 ();

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

1 Expert Approved Answer
Step: 1 Unlock

PriorityQueue Program Plan Define the class Prior ityQueue Define the GeometricObj ect to define the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!