add MidiByteArray::compare_n()

This commit is contained in:
Paul Davis
2016-09-23 12:07:00 -05:00
parent 69a789c513
commit acf586b058
2 changed files with 21 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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
*/