I have priority queue in Java of Integers:
PriorityQueue pq= new PriorityQueue();
When I call pq.poll(
I just ran a Monte-Carlo simulation on both comparators on double heap sort min max and they both came to the same result:
These are the max comparators I have used:
(A) Collections built-in comparator
PriorityQueue heapLow = new PriorityQueue(Collections.reverseOrder());
(B) Custom comparator
PriorityQueue heapLow = new PriorityQueue(new Comparator() {
int compare(Integer lhs, Integer rhs) {
if (rhs > lhs) return +1;
if (rhs < lhs) return -1;
return 0;
}
});