mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
[RigidDeque] Implement replacement operations
This commit is contained in:
7 files changed
+811
-96
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// This source file is part of the Swift Collections open source project
|
||||
//
|
||||
// Copyright (c) 2024 - 2025 Apple Inc. and the Swift project authors
|
||||
// Copyright (c) 2024 - 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
|
||||
@@ -32,11 +32,11 @@ extension RigidArray where Element: ~Copyable {
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, then
|
||||
/// this method is equivalent to calling
|
||||
/// `insert(count: newCount, initializingWith: body)`.
|
||||
/// `insert(count: newCount, at: subrange.lowerbound, initializingWith: body)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero for `newCount`, then this method
|
||||
/// removes the elements in the given subrange without any replacement.
|
||||
/// Calling `removeSubrange(subrange)` is preferred in this case.
|
||||
/// This case is more directly expressed by `removeSubrange(subrange)`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -83,13 +83,13 @@ extension RigidArray where Element: ~Copyable {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(moving:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(moving:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -123,13 +123,13 @@ extension RigidArray where Element: ~Copyable {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(moving:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(moving:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -162,13 +162,13 @@ extension RigidArray where Element: ~Copyable {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(moving:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(moving:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -202,13 +202,13 @@ extension RigidArray where Element: ~Copyable {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(moving:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -221,6 +221,7 @@ extension RigidArray where Element: ~Copyable {
|
||||
_ subrange: Range<Int>,
|
||||
moving newElements: inout RigidArray<Element>,
|
||||
) {
|
||||
// FIXME: Remove this in favor of a generic algorithm over consumable containers
|
||||
unsafe newElements._unsafeEdit { buffer, count in
|
||||
let source = buffer._extracting(first: count)
|
||||
unsafe self.replaceSubrange(subrange, moving: source)
|
||||
@@ -244,13 +245,13 @@ extension RigidArray where Element: ~Copyable {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(consuming:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -283,13 +284,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -321,13 +322,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length buffer as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -357,13 +358,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length span as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -441,13 +442,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length container as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -480,13 +481,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length collection as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
@@ -517,13 +518,13 @@ extension RigidArray {
|
||||
/// elements, then this method triggers a runtime error.
|
||||
///
|
||||
/// If you pass a zero-length range as the `subrange` parameter, this method
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. Calling
|
||||
/// the `insert(copying:at:)` method instead is preferred in this case.
|
||||
/// inserts the elements of `newElements` at `subrange.lowerBound`. This case
|
||||
/// is more directly expressed by calling `insert(copying:at:)`.
|
||||
///
|
||||
/// Likewise, if you pass a zero-length container as the `newElements`
|
||||
/// parameter, this method removes the elements in the given subrange
|
||||
/// without replacement. Calling the `removeSubrange(_:)` method instead is
|
||||
/// preferred in this case.
|
||||
/// without replacement. This case is more directly expressed by calling
|
||||
/// `removeSubrange`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - subrange: The subrange of the array to replace. The bounds of
|
||||
|
||||
Reference in new issue
Block a user