Skip to content

Commit

Permalink
added difference on bitset
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Mar 17, 2024
1 parent 4dd18b5 commit b7dd00a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions include/flatmemory/details/types/bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,30 @@ class Builder<Bitset<Block>> : public IBuilder<Builder<Bitset<Block>>>
return *this;
}

template<IsBitset Other>
Builder& operator-=(const Other& other)
{
// Fetch data
const auto& other_blocks = other.get_blocks();
bool other_default_bit_value = other.get_default_bit_value();

// Update default bit value
m_default_bit_value &= !other_default_bit_value;

// Update blocks
resize_to_fit(other);
auto it = m_blocks.begin();
auto other_it = other_blocks.begin();
while (it != m_blocks.end())
{
*it &= ~(*other_it);
++it;
++other_it;
}

return *this;
}

/**
* Lookup
*/
Expand Down

0 comments on commit b7dd00a

Please sign in to comment.