fork download
  1. #include <unordered_set>
  2. #include <iostream>
  3.  
  4. struct node
  5. {
  6. std::string node_id;
  7. double value;
  8. node(std::string id, double val) : node_id(id), value(val) {}
  9. };
  10.  
  11. int main() {
  12. auto hash = [](const node& n){ return std::hash<std::string>()(n.node_id); };
  13. auto equal = [](const node& n1, const node& n2){ return n1.node_id == n2.node_id; };
  14. std::unordered_set<node, decltype(hash), decltype(equal)> set(8, hash, equal);
  15.  
  16. set.insert(node("1001", 100));
  17. if (set.find(node("1001", 0)) != set.end())
  18. std::cout << "1001 found" << std::endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1001 found