bitSet: add logical_and()/_or()

Basic logical operations for tests
where a temporary can be avoided.
This commit is contained in:
Michael Davidsaver
2016-03-02 18:11:33 -05:00
parent 28b5dd0163
commit a3c57a5077
3 changed files with 47 additions and 4 deletions

View File

@@ -196,6 +196,20 @@ namespace epics { namespace pvData {
return words.size() * BITS_PER_WORD;
}
bool BitSet::logical_and(const BitSet& set) const
{
size_t nwords = std::min(words.size(), set.words.size());
for(size_t i=0; i<nwords; i++) {
if(words[i] & set.words[i])
return true;
}
return false;
}
bool BitSet::logical_or(const BitSet& set) const
{
return !words.empty() || !set.words.empty();
}
BitSet& BitSet::operator&=(const BitSet& set) {
// Check for self-assignment!
if (this == &set) return *this;