mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Merge pull request #263 from lorentey/bitcollections-finalization
BitArray API refinements & additions
This commit is contained in:
24 files changed
+844
-92
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift Collections open source project
|
||||
//
|
||||
// Copyright (c) 2021-2022 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
@@ -83,6 +83,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