Guest User

Untitled

a guest
Sep 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. struct node
  2. {
  3. int label;
  4. long cost=LONG_MAX;
  5. bool visited=false;
  6. bool operator < (const node &other) const { return cost < other.cost; }
  7. }
  8.  
  9. set<node> S;
  10.  
  11. //here i just want to update the cost of a node in my set S
  12.  
  13. set<node>::iterator it=S.find(vertex);
  14. *it.cost=200;
  15.  
  16. auto it = S.find(vertex);
  17. node cur = std::move(*it);
  18. auto next = S.erase(it);
  19. cur.cost = 200;
  20. S.insert(next, cur);
  21.  
  22. auto node = S.extract(vertex);
  23. node.value().cost = 200;
  24. S.insert(std::move(node));
Add Comment
Please, Sign In to add comment