Using PriorityQueue in Java doesn't seems to work properly


While doing the Dr. Who “Cadeau” puzzle I came cross what seems to be a bug.

PriorityQueue queue = new PriorityQueue(N, new BudgetComparator());

I tried to use java.util.PriorityQueue to sort my collection, it works in local using jdk1.7.0_65, unfortunately my queue wasn’t sorting properly on platform.

However, the code below works fine:

List queue = new ArrayList();

Collections.sort(queue, new BudgetComparator());

You use untyped generic types, so it is hard to be affirmative, but I would say it is probably a missing (or an inappropriate) “equals” method override.