I have the following code:
PriorityQueue<Pair<Integer, Double>> pq =
new PriorityQueue<>((v1, v2) -> (int)Math.floor(v1.getValue() - v2.getValue()));
pq.add(new Pair(1, 0));
Pair<Integer, Double> node = pq.poll();
double time = node.getValue();
The last line raises a
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class
java.lang.Double (java.lang.Integer and java.lang.Double are in module
java.base of loader 'bootstrap')
The issue goes away if I replace the second statement with
pq.add(new Pair(1, 0.0));
I'd like to understand what is happening under the hood resulting in this exception.
Pair? Is that a standard class?