fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <unordered_set>
  4.  
  5. using namespace std;
  6.  
  7. struct hasher // Just an example of hash function
  8. {
  9. size_t operator()(const std::vector<int>& val) const
  10. {
  11. size_t ans = 0;
  12. std::hash<int> hasher;
  13. for (auto v : val)
  14. {
  15. ans = ans * 2654435761 + hasher(v);
  16. }
  17. return ans;
  18. }
  19. };
  20.  
  21. int main()
  22. {
  23. unordered_set<vector<int>, hasher> si;
  24. si.insert({ 1, 2 });
  25. si.insert({ 3, 4 });
  26. si.erase({ 1, 2 });
  27. if (si.find({ 1, 2 }) != si.end())
  28. {
  29. cout << "{1, 2} have found" << endl;
  30. }
  31. if (si.find({ 3, 4 }) != si.end())
  32. {
  33. cout << "{3, 4} have found" << endl;
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
{3, 4} have found