A-Star PathFinder Implementation Improvement

Issue #38 new
Anonymous created an issue

The class AStarPathFinder currently keeps an ArrayList of closed Nodes, which it never uses. It is only added to and removed, but nothing more, that's because for determining if a Node is closed or not, is currently done through a flag within the Node itself.

So I request a deletion of the unnecessary List of closed Nodes in the AStarPathFinder class.

Following are the only lines that contain the list.

public class AStarPathFinder implements PathFinder, PathFindingContext {
    /** The set of nodes that have been searched through */
    private ArrayList closed = new ArrayList();

    protected void addToClosed(Node node) {
        node.setClosed(true);
        closed.add(node);
    }
    protected boolean inClosedList(Node node) {
        return node.isClosed();
    }
    protected void removeFromClosed(Node node) {
        node.setClosed(false);
        closed.remove(node);
    }
}

(I know this is micro-optimization, but it simply bugged me while I was looking through the code.)

Comments (0)

  1. Log in to comment