fork(1) download
  1. #include <unordered_set>
  2. #include <iostream>
  3. #include <string>
  4. #include <list>
  5.  
  6. struct Interval {
  7. unsigned int b;
  8. unsigned int e;
  9. bool updated;
  10. int patternIndex;
  11. int proteinIndex;
  12. std::string getID() const { return std::to_string(b) + " " + std::to_string(e) + " " + std::to_string(proteinIndex); }
  13. };
  14.  
  15. int main() {
  16. auto hash = [](const Interval& i){ return std::hash<std::string>()(i.getID()); };
  17. auto equal = [](const Interval& i1, const Interval& i2){ return i1.getID() == i2.getID(); };
  18. std::unordered_set<Interval, decltype(hash), decltype(equal)> test(8, hash, equal);
  19.  
  20. std::list<Interval> concat { {1, 2, false, 3, 4}, {2, 3, false, 4, 5}, {1, 2, true, 7, 4}};
  21.  
  22. for (auto const &i : concat)
  23. test.insert(i);
  24.  
  25. for (auto const &i : test)
  26. std::cout << i.b << ", " << i.e << ", " << i.updated << std::endl;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
2, 3, 0
1, 2, 0