diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-23 12:07:00 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:31 -0500 |
commit | acf586b058598169e9e00d419906a5b7b34bd22f (patch) | |
tree | 3c55ce36e04f005302773287905beaa93acc40fd /libs/surfaces/push2 | |
parent | 69a789c513f473baa079d5b70e8ebf6c37e36b31 (diff) |
add MidiByteArray::compare_n()
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r-- | libs/surfaces/push2/midi_byte_array.cc | 19 | ||||
-rw-r--r-- | libs/surfaces/push2/midi_byte_array.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/libs/surfaces/push2/midi_byte_array.cc b/libs/surfaces/push2/midi_byte_array.cc index 45d0439a75..e66cd7d287 100644 --- a/libs/surfaces/push2/midi_byte_array.cc +++ b/libs/surfaces/push2/midi_byte_array.cc @@ -94,3 +94,22 @@ MidiByteArray & operator << (MidiByteArray & mba, const std::string & st) mba.insert (mba.end(), st.begin(), st.end()); return mba; } + +bool +MidiByteArray::compare_n (const MidiByteArray& other, MidiByteArray::size_type n) const +{ + MidiByteArray::const_iterator us = begin(); + MidiByteArray::const_iterator them = other.begin(); + + while (n && us != end() && them != other.end()) { + if ((*us) != (*them)) { + return false; + } + --n; + ++us; + ++them; + } + + return true; +} + diff --git a/libs/surfaces/push2/midi_byte_array.h b/libs/surfaces/push2/midi_byte_array.h index 3d3bcecd28..f9ab60e31b 100644 --- a/libs/surfaces/push2/midi_byte_array.h +++ b/libs/surfaces/push2/midi_byte_array.h @@ -52,6 +52,8 @@ public: MidiByteArray( size_t count, MIDI::byte array[] ); + bool compare_n (const MidiByteArray& other, MidiByteArray::size_type len) const; + /** Accepts a preceding count, and then a list of bytes */ |