January 2018
Beginner
254 pages
6h 25m
English
We represent our open and closed list using the PriorityQueue class. This approach allows us to implement some helper methods for our own convenience. The PriorityClass.cs file looks like this:
using System.Collections;public class PriorityQueue { private ArrayList nodes = new ArrayList(); public int Length { get { return nodes.Count; } } public bool Contains(object node) { return nodes.Contains(node); } public Node GetFirstNode() { if (nodes.Count > 0) { return (Node)nodes[0]; } return null; } public void Push(Node node) { nodes.Add(node); nodes.Sort(); } public void Remove(Node node) { nodes.Remove(node); nodes.Sort(); }}
There isn't much of note in this code, but the Sort() method in particular is interesting. ...
Read now
Unlock full access