public IEnumerable <T> Solve(T start, T end) { using (openSet = PriorityQueueCache <float, AStarNode <T> > .GetQueue()) { AStarNode <T> startNode = new AStarNode <T>(start, 0f, GetHScore(start, end), null); nodes[start] = startNode; TryOpenNode(start); while (openSet.Count != 0) { var current = openSet.Dequeue().value; if (current.node == end) { return(TracePath(current)); } TryCloseNode(current.node); foreach (var adjacent in GetAdjacent(current.node)) { UpdateGScore(adjacent, current.node, end); TryOpenNode(adjacent); } } return(TracePath(bestResultSoFar.bestAStarNode)); } }
public void Dispose() { Clear(); PriorityQueueCache <T, U> .AddQueue(this); }