mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
[BitCollections] BitSet.isSubset(of: Range<Int>): also look at elements above the range's upper word
This commit is contained in:
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>)] = [
|
||||
|
||||
Reference in new issue
Block a user