MessageList.cpp 902 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "MessageList.h"
  2. namespace midi {
  3. bool MessageList::contains(const Message& message) const
  4. {
  5. return find(message) != end();
  6. }
  7. MessageList::iterator MessageList::find(const Message& message)
  8. {
  9. for(iterator it = begin(); it != end(); it++) {
  10. if(message == **it) {
  11. return it;
  12. }
  13. }
  14. return end();
  15. }
  16. MessageList::const_iterator MessageList::find(const Message& message) const
  17. {
  18. for(const_iterator it = begin(); it != end(); it++) {
  19. if(message == **it) {
  20. return it;
  21. }
  22. }
  23. return end();
  24. }
  25. void MessageList::print(std::ostream& stream) const
  26. {
  27. stream << "midi message list:\n";
  28. unsigned int i = 0;
  29. for(const_iterator msg_it = begin(); msg_it != end(); msg_it++, i++) {
  30. stream << "#" << i << " ";
  31. (*msg_it)->print(stream);
  32. }
  33. stream << "\n";
  34. stream.flush();
  35. }
  36. }; // namespace