I got a simple priority queue of <node> objects.
Priority Queue<node> queue = new Priority Queue<node>(n,compare);
the node object has a few fields, one of them an int field called LB(lower bound)
I've build a compare class so the queue would use my compare to sort itself.
The problem is that when I'm trying to add the first object to the queue I get nullpointerexception.
I assume that it's because he doesn't have anything to compare to.
this is the compare function.
I've tried adding a condition so that if one of the nodes X or Y is null return 1 but it didn't help
import java.util.Comparator;
public class nodecompartor implements Comparator<node> {
public int compare(node x,node y)
{
if(x.getLB()>=y.getLB())
return 1;
if(x.getLB()<y.getLB())
return -1;
return 0;
}
}
thanks
Arthur