我有以下python代码:
import heapq
heapq.heappush(openList, currentSearchNode)
#NOTE List of nodes that have been checked
closedList = []
while openList:
#NOTE Pop the lowest fscore (to-go + been from or gScore + hScore) and set it as current
currentSearchNode = heapq.heappop(openList)
...我需要把它转换成C++14,我试过了:
#include <functional>
#include <queue>
priority_queue <Node, vector<Node>, greater<Node>> min_heap;
vector<Node> openList, closeList;
Node currentNode = Node(start, euclidean(start, end), 0);
min_heap.emplace(openList, currentNode);
while (!openList.empty()) {
currentNode = min_heap.pop(openList);
...
}在Visual Studio中弹出红色的唯一问题是你可以看到的这一行currentNode = min_heap.pop(openList);,它说,pop的参数太多了。怎样做才是正确的呢?
发布于 2020-08-30 10:41:12
如下所示如何?
while (!min_heap.empty()) {
currentNode = min_heap.top(); // sets the top small (since std::greater used)element to currentNode;
/* do something with currentNode */
min_heap.pop(); // pops the element from container
}https://stackoverflow.com/questions/63653383
复制相似问题