Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- auto it = S.find(vertex);
- node cur = std::move(*it);
- auto next = S.erase(it);
- cur.cost = 200;
- S.insert(next, cur);
- auto node = S.extract(vertex);
- node.value().cost = 200;
- S.insert(std::move(node));
Add Comment
Please, Sign In to add comment