mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
Merge pull request #682 from lorentey/container-updates
[ContainersPreview] Update Container protocols
This commit is contained in:
152 files changed
+5790
-2272
No files matched your search
@@ -87,15 +87,15 @@ internal struct _ChunkedBitsBackwardIterator {
|
||||
|
||||
extension IteratorProtocol where Element == Bool {
|
||||
mutating func _nextChunk(
|
||||
maximumCount: UInt = _Word._capacity
|
||||
maxCount: UInt = _Word._capacity
|
||||
) -> (bits: _Word, count: UInt) {
|
||||
assert(maximumCount <= _Word.capacity)
|
||||
assert(maxCount <= _Word.capacity)
|
||||
var bits = _Word.empty
|
||||
var c: UInt = 0
|
||||
while let v = next() {
|
||||
if v { bits.insert(c) }
|
||||
c += 1
|
||||
if c == maximumCount { break }
|
||||
if c == maxCount { break }
|
||||
}
|
||||
return (bits, c)
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ extension BitArray._UnsafeHandle {
|
||||
var it = source.makeIterator()
|
||||
if pos.bit > 0 {
|
||||
let (bits, count) = it._nextChunk(
|
||||
maximumCount: _Word._capacity - pos.bit)
|
||||
maxCount: _Word._capacity - pos.bit)
|
||||
_copy(bits: bits, count: count, to: pos)
|
||||
pos.value += count
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ extension BitArray {
|
||||
var pos = _BitPosition(_count)
|
||||
if pos.bit > 0 {
|
||||
let (bits, count) = it._nextChunk(
|
||||
maximumCount: _Word._capacity - pos.bit)
|
||||
maxCount: _Word._capacity - pos.bit)
|
||||
guard count > 0 else { return }
|
||||
_count += count
|
||||
_update { $0._copy(bits: bits, count: count, to: pos) }
|
||||
|
||||
Reference in new issue
Block a user