mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Key Changes:
- Implement Equatable, Hashable for SubSequences
- Implement SortedDictionary initializers
- init(keysWithValues:) and init(sortedKeysAndValues:) with named and unnamed variants.
- Expand benchmark suite for SortedDictionary
- Commit _BTree.Builder
Minor Changes:
- Update documentation
- Expand test suits
- Fix bug where SubSequences did not define subscript(bounds: Range<Index>)
- _Node
- Implement `depth` property for `_Node`
- Packs both `depth`, `count`, and `capacity` within a single UInt64.
- Implement `init(leftChild:seperator:rightChild:capacity:)` for `_Node`
- Implement `concatenateWith(node:seperatedBy:)` to `_Node.UnsafeHandle`
- Remove bad invariant check on `_Node.UnsafeHandle` deletion subroutines
- _BTree
- Add invariant checks as `_BTree.checkInvariants()`
- Separate `_BTree.*capacity` into `*size` and `*capacity`
- Make _FixedSizeArray top-level
- Remove deque behavior.
Documentation:
- Update complexity documentation style from 'n' to `self.count`
Testing:
- Expand tests for SortedDictionary
- Add tests for SortedDictionary.Keys
- Add tests for _Node.join(...) routines
- Add tests for _BTree.Builder
- Restore checkBidirectionalCollection tests for _BTree
52 lines
1.6 KiB
Swift
52 lines
1.6 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift Collections open source project
|
|
//
|
|
// Copyright (c) 2021 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
extension _Node {
|
|
/// Represents the result of a overfilled node's split.
|
|
@usableFromInline
|
|
internal struct Splinter {
|
|
@inlinable
|
|
@inline(__always)
|
|
internal init(element: Element, rightChild: _Node<Key, Value>) {
|
|
self.element = element
|
|
self.rightChild = rightChild
|
|
}
|
|
|
|
/// The former median element which should be propogated upward.
|
|
@usableFromInline
|
|
internal let element: Element
|
|
|
|
/// The right product of the node split.
|
|
@usableFromInline
|
|
internal var rightChild: _Node<Key, Value>
|
|
|
|
/// Converts the splinter object to a node.
|
|
/// - Parameters:
|
|
/// - node: The node generating the splinter. Becomes the returned
|
|
/// node's left child.
|
|
/// - capacity: The desired capacity of the new node.
|
|
/// - Returns: A new node of `capacity` with a single element.
|
|
@inlinable
|
|
@inline(__always)
|
|
internal __consuming func toNode(
|
|
leftChild: _Node<Key, Value>,
|
|
capacity: Int
|
|
) -> _Node {
|
|
return _Node(
|
|
leftChild: leftChild,
|
|
seperator: element,
|
|
rightChild: rightChild,
|
|
capacity: capacity
|
|
)
|
|
}
|
|
}
|
|
}
|