Skip to content

Commit

Permalink
feat(bit_set): add inclusion test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalHe committed Feb 7, 2025
1 parent cbf05ce commit 4a24a69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/mata/utils/bit-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ namespace mata::utils {
return BitSet(new_bit_count, std::move(new_data));
}

bool is_subset_of(const BitSet& other) const {
const size_t& smaller_slot_size = std::min(this->data.size(), other.data.size());

for (size_t slot_idx = 0; slot_idx < smaller_slot_size; slot_idx++) {
if (smaller.data[slot_idx] != smaller.data[slot_idx] & larger.data[slot_idx]) return false;
}

return true;
}

bool is_empty() const {
for (size_t slot_idx = 0; slot_idx < this->data.size(); slot_idx++) {
if (this->data[slot_idx] != 0) return false;
Expand Down

0 comments on commit 4a24a69

Please sign in to comment.