我想使用一组S类型node,我想操纵集合中的成本部分并按以下顺序对集合进行排序cost:
struct node
{
int label;
long cost=LONG_MAX;
bool visited=false;
bool operator < (const node &other) const { return cost < other.cost; }
}
set<node> S;
//here i just want to update the cost of a node in my set S
set<node>::iterator it=S.find(vertex);
*it.cost=200;
Run Code Online (Sandbox Code Playgroud)
这是否会自动更改集合中的顺序?