November 2018
Beginner
246 pages
5h 23m
English
A PriorityQueue is an ordered data structure that's designed in such a way that the first element (the head) of the list is always the smallest or largest element (depending on the implementation). We will use this data structure to handle the nodes in the open list because we need to find the node with the smallest F value efficiently. The code for this is shown in the following PriorityQueue.cs class:
using UnityEngine; using System.Collections; public class PriorityQueue { private ArrayList nodes = new ArrayList(); public int Length { get { return this.nodes.Count; } } public bool Contains(object node) { return this.nodes.Contains(node); } public Node First() { if (this.nodes.Count > 0) { return (Node)this.nodes[0]; } return ...Read now
Unlock full access