13
0

'libs/evoral' - For each of the NNNN_lower_bound() functions (3 in total) add a non-const iterator to supplement the existing const_iterator

This commit is contained in:
John Emmas 2013-07-23 07:56:30 +01:00
parent af51ef383d
commit bc34d6f731
2 changed files with 45 additions and 3 deletions

View File

@ -179,7 +179,7 @@ public:
OverlapPitchResolution overlap_pitch_resolution() const { return _overlap_pitch_resolution; }
void set_overlap_pitch_resolution(OverlapPitchResolution opr);
void set_notes (const Sequence<Time>::Notes& n);
void set_notes (const typename Sequence<Time>::Notes& n);
typedef boost::shared_ptr< Event<Time> > SysExPtr;
typedef boost::shared_ptr<const Event<Time> > constSysExPtr;
@ -269,10 +269,16 @@ public:
const const_iterator& end() const { return _end_iter; }
// CONST iterator implementations (x3)
typename Notes::const_iterator note_lower_bound (Time t) const;
typename PatchChanges::const_iterator patch_change_lower_bound (Time t) const;
typename SysExes::const_iterator sysex_lower_bound (Time t) const;
// NON-CONST iterator implementations (x3)
typename Notes::iterator note_lower_bound (Time t);
typename PatchChanges::iterator patch_change_lower_bound (Time t);
typename SysExes::iterator sysex_lower_bound (Time t);
bool control_to_midi_event(boost::shared_ptr< Event<Time> >& ev,
const ControlIterator& iter) const;

View File

@ -1201,11 +1201,13 @@ Sequence<Time>::overlaps_unlocked (const NotePtr& note, const NotePtr& without)
template<typename Time>
void
Sequence<Time>::set_notes (const Sequence<Time>::Notes& n)
Sequence<Time>::set_notes (const typename Sequence<Time>::Notes& n)
{
_notes = n;
}
// CONST iterator implementations (x3)
/** Return the earliest note with time >= t */
template<typename Time>
typename Sequence<Time>::Notes::const_iterator
@ -1239,6 +1241,41 @@ Sequence<Time>::sysex_lower_bound (Time t) const
return i;
}
// NON-CONST iterator implementations (x3)
/** Return the earliest note with time >= t */
template<typename Time>
typename Sequence<Time>::Notes::iterator
Sequence<Time>::note_lower_bound (Time t)
{
NotePtr search_note(new Note<Time>(0, t, 0, 0, 0));
typename Sequence<Time>::Notes::iterator i = _notes.lower_bound(search_note);
assert(i == _notes.end() || (*i)->time() >= t);
return i;
}
/** Return the earliest patch change with time >= t */
template<typename Time>
typename Sequence<Time>::PatchChanges::iterator
Sequence<Time>::patch_change_lower_bound (Time t)
{
PatchChangePtr search (new PatchChange<Time> (t, 0, 0, 0));
typename Sequence<Time>::PatchChanges::iterator i = _patch_changes.lower_bound (search);
assert (i == _patch_changes.end() || musical_time_greater_or_equal_to ((*i)->time(), t));
return i;
}
/** Return the earliest sysex with time >= t */
template<typename Time>
typename Sequence<Time>::SysExes::iterator
Sequence<Time>::sysex_lower_bound (Time t)
{
SysExPtr search (new Event<Time> (0, t));
typename Sequence<Time>::SysExes::iterator i = _sysexes.lower_bound (search);
assert (i == _sysexes.end() || (*i)->time() >= t);
return i;
}
template<typename Time>
void
Sequence<Time>::get_notes (Notes& n, NoteOperator op, uint8_t val, int chan_mask) const
@ -1393,4 +1430,3 @@ Sequence<Time>::dump (ostream& str) const
template class Sequence<Evoral::MusicalTime>;
} // namespace Evoral