Skip to content

Instantly share code, notes, and snippets.

@aybabtme
Created March 30, 2013 18:37
Show Gist options
  • Save aybabtme/5277848 to your computer and use it in GitHub Desktop.
Save aybabtme/5277848 to your computer and use it in GitHub Desktop.
that = this in Java
private Comparator<Vertex<Value>> getComparator(){
final Vertex<Value> that = this;
return new Comparator<Vertex<Value>>() {
@Override
public int compare(Vertex<Value> v1, Vertex<Value> v2) {
double h1 = heuristic.getCost(that, v1);
double h2 = heuristic.getCost(that, v2);
double d1 = that.distanceTo(v1);
double d2 = that.distanceTo(v2);
double costOfV1 = h1 + d1;
double costOfV2 = h2 + d2;
return (int) (costOfV1 - costOfV2);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment