I'm initialising a Priority Queue like:
strategy = new FuelPriority();
incoming = new PriorityQueue<Vehicle>(1, strategy);
The code for my Comparator class is:
public class FuelPriority implements Comparator<Object> {
public int compare(Object o1, Object o2) {
Vehicle a1 = (Vehicle) o1;
Vehicle a2 = (Vheicle) o2;
return Integer.compare(a1.getFuelLevel(), a2.getFuelLevel());
}
}
After running a simulation, the elements aren't ordered at all - they are random; I set a breakpoint in the compare method of my FuelPriority class, but it wasn't called at all.
Am I missing something here?