gpt4 book ai didi

c++ - 如果您在 C++ 中更新集合的成员,集合会自动更改顺序吗?

转载 作者:太空狗 更新时间:2023-10-29 21:15:34 25 4
gpt4 key购买 nike

<分区>

我想使用 node 类型的集合 S 并且我想操作集合中的成本部分并按 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;

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com