diff options
Diffstat (limited to 'muse2/muse/eventlist.cpp')
-rw-r--r-- | muse2/muse/eventlist.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/muse2/muse/eventlist.cpp b/muse2/muse/eventlist.cpp index 50ba2652..80180ab7 100644 --- a/muse2/muse/eventlist.cpp +++ b/muse2/muse/eventlist.cpp @@ -62,7 +62,7 @@ void EventList::read(Xml& xml, const char* name, bool midi) // add //--------------------------------------------------------- -iEvent EventList::add(Event& event) +iEvent EventList::add(Event event) { // Changed by Tim. An event list containing wave events should be sorted by // frames. WaveTrack::fetchData() relies on the sorting order, and @@ -129,17 +129,51 @@ void EventList::move(Event& event, unsigned tick) //--------------------------------------------------------- iEvent EventList::find(const Event& event) +{ + std::pair<iEvent,iEvent> range = equal_range(event.type() == Wave ? event.frame() : event.tick()); + + for (iEvent i = range.first; i != range.second; ++i) { + if (i->second == event) + return i; + } + return end(); +} + +ciEvent EventList::find(const Event& event) const { EventRange range = equal_range(event.type() == Wave ? event.frame() : event.tick()); - for (iEvent i = range.first; i != range.second; ++i) { + for (ciEvent i = range.first; i != range.second; ++i) { if (i->second == event) return i; } return end(); } +iEvent EventList::findSimilar(const Event& event) +{ + std::pair<iEvent,iEvent> range = equal_range(event.type() == Wave ? event.frame() : event.tick()); + + for (iEvent i = range.first; i != range.second; ++i) { + if (i->second.isSimilarTo(event)) + return i; + } + return end(); +} + +ciEvent EventList::findSimilar(const Event& event) const + { + EventRange range = equal_range(event.type() == Wave ? event.frame() : event.tick()); + + + for (ciEvent i = range.first; i != range.second; ++i) { + if (i->second.isSimilarTo(event)) + return i; + } + return end(); + } + //--------------------------------------------------------- // dump //--------------------------------------------------------- |