mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
[BasicContainers] Add early drafts for RigidSet/RigidDictionary
This commit is contained in:
36 files changed
+2411
-51
No files matched your search
@@ -42,7 +42,7 @@ internal struct _ChunkedBitsForwardIterator {
|
||||
.shiftedDown(by: b),
|
||||
count: end.bit - b)
|
||||
}
|
||||
let c = UInt(_Word.capacity) - b
|
||||
let c = _Word._capacity - b
|
||||
position.value += c
|
||||
return (bits: words[w].shiftedDown(by: b), count: c)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ internal struct _ChunkedBitsBackwardIterator {
|
||||
|
||||
extension IteratorProtocol where Element == Bool {
|
||||
mutating func _nextChunk(
|
||||
maximumCount: UInt = UInt(_Word.capacity)
|
||||
maximumCount: UInt = _Word._capacity
|
||||
) -> (bits: _Word, count: UInt) {
|
||||
assert(maximumCount <= _Word.capacity)
|
||||
var bits = _Word.empty
|
||||
|
||||
@@ -79,7 +79,7 @@ extension BitArray._UnsafeHandle {
|
||||
words[start.word].formUnion(bits.shiftedUp(by: start.bit))
|
||||
words[end.word].formIntersection(_Word(upTo: end.bit).complement())
|
||||
words[end.word].formUnion(
|
||||
bits.shiftedDown(by: UInt(_Word.capacity) &- start.bit))
|
||||
bits.shiftedDown(by: _Word._capacity &- start.bit))
|
||||
}
|
||||
|
||||
internal mutating func copy(
|
||||
@@ -160,7 +160,7 @@ extension BitArray._UnsafeHandle {
|
||||
var it = source.makeIterator()
|
||||
if pos.bit > 0 {
|
||||
let (bits, count) = it._nextChunk(
|
||||
maximumCount: UInt(_Word.capacity) - pos.bit)
|
||||
maximumCount: _Word._capacity - pos.bit)
|
||||
_copy(bits: bits, count: count, to: pos)
|
||||
pos.value += count
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ extension BitArray {
|
||||
var pos = _BitPosition(_count)
|
||||
if pos.bit > 0 {
|
||||
let (bits, count) = it._nextChunk(
|
||||
maximumCount: UInt(_Word.capacity) - pos.bit)
|
||||
maximumCount: _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