[BitCollections] BitSet.isSubset(of: Range<Int>): also look at elements above the range's upper word

This commit is contained in:
Karoy Lorentey committed 2026-05-01 14:33:28 -07:00
1 parent 9364ee33b1
commit cef6301d19
2 files changed
+4

No files matched your search

@@ -191,6 +191,9 @@ extension _UnsafeBitSet {
let hw = _Word(upTo: upper.bit).complement()
guard _words[upper.word].intersection(hw).isEmpty else { return false }
for w in upper.word + 1 ..< wordCount {
guard _words[w].isEmpty else { return false }
}
return true
}
@@ -1218,6 +1218,7 @@ final class BitSetTest: CollectionTestCase {
"a": BitSet(10*step ..< 20*step),
"b": BitSet(10*step ..< 20*step).subtracting(13*step ..< 14*step),
"c": BitSet(10*step ..< 20*step - 1),
"d": BitSet(10*step ..< 20*step).union(100*step ..< 110*step),
]
let tests: [(range: Range<Int>, expected: Set<String>)] = [