Hi all,
I need a priority queue of objects but I keep getting this error:
symbol: constructor PriorityQueue(anonymous java.util.Comparator<map.Node>>)
location: class java.util.PriorityQueue<map.Node>
PriorityQueue<Node> pq = new PriorityQueue<Node>(new Comparator<Node>()
Here an excerpt from my code:
public class map {
static class Node {
Node parent;
State state;
private int cost;
public Node() {};
public Node(Node parent_passed, State state_passed, Integer cost_passed ) {
this.parent = parent_passed;
this.state = state_passed;
this.cost = cost_passed;
}
public int getCost()
{
return cost;
}
}
public static void main(String[] args)
{
PriorityQueue<Node> pq = new PriorityQueue<Node>(new Comparator<Node>()
{
public int compare(Node a1, Node a2) {
return a2.getCost() - a1.getCost();
}
});
}
Any ideas? Do I need to make the Node class public and put it in it's own file?