I want to keep two things in the priority queue ... one is the number and the other is the cost. that is, I want to do the following:
PriorityQueue<Integer, Cost> q=new PriorityQueue<Integer, Cost>();
Cost is another class that I hav:
class Cost implements Comparable<Cost> { String name; double cost; @Override public int compareTo(Cost s) { return Double.compare(cost, s.cost); } }
Also, I want to perform comparisons only on the basis of value ... but I also want some integer identifier to be transmitted along with the value ... is there any way to achieve this?
I need to get the value based on id..so I use a hash map for it. When using the id field in value ... I want to get the entire cost instance based on this identifier field ... is it possible ... yes, then how?
I am new to Java programming. Can anyone suggest some way out?
source share