fork download
  1. #include <unordered_set>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. class Sales_data
  7. {
  8. public:
  9. string isbn()const {return a;}
  10. private:
  11. string a;
  12. };
  13.  
  14. size_t hasher(const Sales_data &sd)
  15. {
  16. return hash<string>()(sd.isbn());
  17. }
  18. bool eqOp(const Sales_data &lhs, const Sales_data &rhs)
  19. {
  20. return lhs.isbn() == rhs.isbn();
  21. }
  22.  
  23. int main()
  24. {
  25. using SD_multiset = unordered_multiset<Sales_data,decltype(hasher)*, decltype(eqOp)*>;
  26. // arguments are the bucket size and pointers to the hash function and equality operator
  27. SD_multiset bookstore(42, hasher, eqOp);
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty