Files
swift-collections/Sources/SortedCollections/BTree/_Node.Splinter.swift
T
Anton Karpov ed41e49a16 [SortedCollections] Name the documented arguments the way the declarations name them
Same species as #701, in the module behind the UnstableSortedCollections
trait. 16 doc comments name an argument the declaration does not have, and
one block documents a function that is no longer there.

The Keys and Values views carry the same four each: - Parameter i where the
argument is index, and - Parameter index on subscript(position:).

In the B-tree internals the descriptions usually name the right thing while
the key does not: - node on toNode(leftChild:) says the argument becomes the
left child, and - newElement on exchangeChild(atSlot:with newChild:) says it
is the new child.

_BTree.swift keeps a doc block for a function that was removed: it documents
an offset parameter and sits above an unrelated declaration.
2026-08-16 21:52:31 +03:00

58 lines
1.7 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021 - 2026 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
//
// SPDX-License-Identifier: Apache-2.0 WITH Swift-exception
//
//===----------------------------------------------------------------------===//
#if UnstableSortedCollections
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 propagated 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:
/// - leftChild: 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,
separator: element,
rightChild: rightChild,
capacity: capacity
)
}
}
}
#endif