Add IndexSet::isDisjointWith

This commit is contained in:
Andrew Trick
2025-03-23 14:45:58 -07:00
parent f8ab391737
commit 1964f07346
2 changed files with 9 additions and 0 deletions

View File

@@ -197,6 +197,7 @@ public:
bool isSubsetOf(IndexSubset *other) const;
bool isSupersetOf(IndexSubset *other) const;
bool isDisjointWith(IndexSubset *other) const;
IndexSubset *adding(unsigned index, ASTContext &ctx) const;
IndexSubset *extendingCapacity(ASTContext &ctx,

View File

@@ -52,6 +52,14 @@ bool IndexSubset::isSupersetOf(IndexSubset *other) const {
return true;
}
bool IndexSubset::isDisjointWith(IndexSubset *other) const {
assert(capacity == other->capacity);
for (auto index : range(numBitWords))
if (getBitWord(index) & other->getBitWord(index))
return false;
return true;
}
IndexSubset *IndexSubset::adding(unsigned index, ASTContext &ctx) const {
assert(index < getCapacity());
if (contains(index))