小编mei*_*nub的帖子

如果您在c ++中更新集合的成员,该集合是否会自动更改顺序?

我想使用一组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)

这是否会自动更改集合中的顺序?

c++ set

3
推荐指数
1
解决办法
82
查看次数

标签 统计

c++ ×1

set ×1