mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
[Capsule] Add sequence representations for slices
This commit is contained in:
1 parent
8563a916a8
commit
810f22d976
1 file changed
+17
-2
@@ -98,11 +98,26 @@ final class BitmapIndexedDictionaryNode<Key, Value>: DictionaryNode where Key: H
|
||||
}
|
||||
|
||||
var nodeSliceInvariant: Bool {
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).prefix(bitmapIndexedNodeArity).allSatisfy { $0 is ReturnBitmapIndexedNode }
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).prefix(header.nodeCount).allSatisfy { $0 is ReturnBitmapIndexedNode }
|
||||
}
|
||||
|
||||
var collSliceInvariant: Bool {
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).suffix(hashCollisionNodeArity).allSatisfy { $0 is ReturnHashCollisionNode }
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).suffix(header.collCount).allSatisfy { $0 is ReturnHashCollisionNode }
|
||||
}
|
||||
|
||||
// TODO: should not materialize as `Array` for performance reasons
|
||||
var _dataSlice: [ReturnPayload] {
|
||||
UnsafeMutableBufferPointer(start: dataBaseAddress, count: header.dataCount).map { $0 }
|
||||
}
|
||||
|
||||
// TODO: should not materialize as `Array` for performance reasons
|
||||
var _nodeSlice: [ReturnBitmapIndexedNode] {
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).prefix(header.nodeCount).map { $0 as! ReturnBitmapIndexedNode }
|
||||
}
|
||||
|
||||
// TODO: should not materialize as `Array` for performance reasons
|
||||
var _collSlice: [ReturnHashCollisionNode] {
|
||||
UnsafeMutableBufferPointer(start: trieBaseAddress, count: header.trieCount).suffix(header.collCount).map { $0 as! ReturnHashCollisionNode }
|
||||
}
|
||||
|
||||
init(dataCapacity: Capacity, trieCapacity: Capacity) {
|
||||
|
||||
Reference in new issue
Block a user