fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <set>
  4. using namespace std;
  5.  
  6. struct IMidiMsgExt {
  7. int mTick;
  8. int mNote;
  9. };
  10.  
  11. struct IMidiMsgExtComp {
  12. bool operator()(const IMidiMsgExt& lhs, const IMidiMsgExt& rhs) {
  13. return lhs.mTick < rhs.mTick;
  14. }
  15. };
  16.  
  17. int main() {
  18. multiset<IMidiMsgExt, IMidiMsgExtComp> playingNotes;
  19.  
  20. playingNotes.emplace(IMidiMsgExt{13, 0});
  21. playingNotes.emplace(IMidiMsgExt{13, 60});
  22. playingNotes.emplace(IMidiMsgExt{13, 60});
  23. playingNotes.emplace(IMidiMsgExt{42, 0});
  24. playingNotes.emplace(IMidiMsgExt{42, 60});
  25.  
  26. for(auto& i : playingNotes) {
  27. cout << i.mTick << ' ' << i.mNote << endl;
  28. }
  29.  
  30. cout << endl;
  31.  
  32. const auto it = find_if(cbegin(playingNotes), cend(playingNotes), [value = int{60}](const auto& i){return i.mNote == value;});
  33.  
  34. if(it != cend(playingNotes)) {
  35. playingNotes.erase(it);
  36. }
  37.  
  38. for(auto& i : playingNotes) {
  39. cout << i.mTick << ' ' << i.mNote << endl;
  40. }
  41. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
13 0
13 60
13 60
42 0
42 60

13 0
13 60
42 0
42 60