Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexedAStarPathFinder uses == where .equals() might be better #67

Closed
ShardPhoenix opened this issue Mar 21, 2016 · 1 comment
Closed

Comments

@ShardPhoenix
Copy link

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.

@davebaol
Copy link
Member

This is kinda related to issue #24.
Probably the method isGoal(current.node) would be more general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants