示例#1
0
    public PQitem RemoveFirst()
    {
        PQitem first = queue[0];

        queue.RemoveAt(0);
        return(first);
    }
示例#2
0
 public void AddConnections(PQitem origin)
 {
     foreach (GraphNode connection in origin.node.connections)
     {
         if (!finished.Contains(connection))
         {
             InsertToPQ(origin, connection);
         }
     }
     finished.Add(origin.node);
 }
示例#3
0
    public void InsertToPQ(PQitem origin, GraphNode node)
    {
        PQitem pqi = new PQitem(origin.node, node);

        pqi.totalDist = 1 + Vector3.Distance(node.pos, end) + origin.totalDist;
        for (var i = 0; i < queue.Count; i++)
        {
            if (pqi.totalDist < queue[i].totalDist)
            {
                queue.Insert(i, pqi);
                return;
            }
        }
        queue.Add(pqi);
    }