mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Review & update BitSet
This is a work in progress; in particular, it adds a cached `count` to BitSet, which may turn out to be a bad idea. (It generates extra work for bulk operations even if the count is never needed.) I think replacing this with a cached `startIndex` might be more useful in practice. The `_UnsafeBitset` type from the OrderedCollections module is brought over as `BitSet._UnsafeHandle`. This implements an (internal-only) fixed-size bitset. `BitSet` now conforms to `SetAlgebra`. We decided against this in the initial implementation, but on reflection, it seems like the right move. (The somewhat nonsensical `insert` and `update` methods are unfortunate, but consistency is valuable.)
This commit is contained in:
1 parent
8463f381fc
commit
8f2e0c79c3
33 files changed
+2863
-866
No files matched your search
@@ -66,6 +66,8 @@ public struct BitArray: ExpressibleByArrayLiteral, Codable {
|
||||
excess = WORD(count%(WORD.bitWidth))
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// Creates a new BitArray using a BitSet, where the indices in the BitSet become the true values in the BitArray. The resulting BitArray often contains many padded false values at the end from empty bits that fill up the word
|
||||
///
|
||||
/// The following example creates a BitArray initialized by a BitSet
|
||||
@@ -82,7 +84,7 @@ public struct BitArray: ExpressibleByArrayLiteral, Codable {
|
||||
storage = bitSet.storage.storage
|
||||
excess = bitSet.storage.excess
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user