IndexedAStarPathFinder uses == where .equals() might be better
ShardPhoenix opened this issue · 1 comments
ShardPhoenix commented
In IndexedAStarPathFinder#search there is this line:
// Terminate if we reached the goal node
if (current.node == endNode) return true;
This only works if nodes don't change identity. Depending on how the user implements methods such as getConnections, the nodes might change identity while still remaining logically equal (eg if the type N is the user's custom Coordinate class). I ran into this problem myself, but fixed it by caching my coordinate objects (which I should have been doing anyway), but it's potentially confusing for less experienced developers. If there isn't a compelling reason to to do otherwise, it might be better to replace the == with .equals.