Skip to content

Commit 1964f07

Browse files
committed
Add IndexSet::isDisjointWith
1 parent f8ab391 commit 1964f07

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/swift/AST/IndexSubset.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ class IndexSubset : public llvm::FoldingSetNode {
197197

198198
bool isSubsetOf(IndexSubset *other) const;
199199
bool isSupersetOf(IndexSubset *other) const;
200+
bool isDisjointWith(IndexSubset *other) const;
200201

201202
IndexSubset *adding(unsigned index, ASTContext &ctx) const;
202203
IndexSubset *extendingCapacity(ASTContext &ctx,

lib/AST/IndexSubset.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ bool IndexSubset::isSupersetOf(IndexSubset *other) const {
5252
return true;
5353
}
5454

55+
bool IndexSubset::isDisjointWith(IndexSubset *other) const {
56+
assert(capacity == other->capacity);
57+
for (auto index : range(numBitWords))
58+
if (getBitWord(index) & other->getBitWord(index))
59+
return false;
60+
return true;
61+
}
62+
5563
IndexSubset *IndexSubset::adding(unsigned index, ASTContext &ctx) const {
5664
assert(index < getCapacity());
5765
if (contains(index))

0 commit comments

Comments
 (0)