C中的人将节点推入优先级队列,我们不得不重载<运算符.是否有类似于python优先级队列中的任何内容.
例如在C:
struct node
{
int city , weight
}
bool operator < (node a, node b)
{
return a.weight > b.weight;
}
int main()
{
node a,b,c;
priority_queue <node> pq;
pq.push(a);pq.push(b);pq.push(c);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
有没有类似的方法来定义Python中的优先级队列; 如果需要帮助,我无法在python.org文档的头部或尾部进行优先级排队.我在stackoverflow上看到了几个解释,需要更多的解释.谢谢.