Change priorityQueue to max priorityqueue
Change priorityQueue to max priorityqueue I have priority queue in Java of Integers: PriorityQueue<Integer> pq= new PriorityQueue<Integer>(); When I call pq.poll() I get the minimum element. pq.poll() Question: how to change the code to get the maximum element? I think you should use the constructor that receives a comparator for that. Use the Collections.reverseOrder to obtain a reversed comparator. – Edwin Dalorzo Jun 12 '12 at 19:08 you need to pass a comparator. see stackoverflow.com/questions/683041/… – DarthVader Jun 12 '12 at 19:08 10 Answers 10 How about like this: PriorityQueue...
