mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
[BitArray] Add BitArray → BinaryInteger conversion initializers
extension BinaryInteger {
public init(truncatingIfNeeded source: BitArray)
public init?(exactly source: BitArray)
public init(_ source: BitArray)
}
This commit is contained in:
2 files changed
+253
-1
No files matched your search
@@ -81,6 +81,24 @@ extension BitArray._UnsafeHandle {
|
||||
Int(_count)
|
||||
}
|
||||
|
||||
internal var end: _BitPosition {
|
||||
_BitPosition(_count)
|
||||
}
|
||||
|
||||
internal func set(at position: Int) {
|
||||
ensureMutable()
|
||||
assert(position >= 0 && position < _count)
|
||||
let (word, bit) = _BitPosition(UInt(position)).split
|
||||
_mutableWords[word].insert(bit)
|
||||
}
|
||||
|
||||
internal func clear(at position: Int) {
|
||||
ensureMutable()
|
||||
assert(position >= 0 && position < _count)
|
||||
let (word, bit) = _BitPosition(UInt(position)).split
|
||||
_mutableWords[word].remove(bit)
|
||||
}
|
||||
|
||||
internal subscript(position: Int) -> Bool {
|
||||
get {
|
||||
assert(position >= 0 && position < _count)
|
||||
|
||||
Reference in new issue
Block a user