From b9fd3ed56e97a3dc6cdcf70b01e39c72f7b217f7 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Thu, 5 Feb 2026 16:46:14 -0800 Subject: [PATCH] RigidArray, UniqueArray: Move remaining deprecations to dedicated file --- .../RigidArray/RigidArray+Deprecated.swift | 53 ++++++++++++++++++- .../RigidArray/RigidArray.swift | 47 ---------------- .../UniqueArray/UniqueArray+Deprecated.swift | 23 ++++++++ .../UniqueArray/UniqueArray.swift | 26 --------- 4 files changed, 74 insertions(+), 75 deletions(-) diff --git a/Sources/BasicContainers/RigidArray/RigidArray+Deprecated.swift b/Sources/BasicContainers/RigidArray/RigidArray+Deprecated.swift index 1ae26624..459d1341 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray+Deprecated.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray+Deprecated.swift @@ -41,7 +41,7 @@ extension RigidArray where Element: ~Copyable { } return result.take()! } - + /// Inserts a given number of new items into this array at the specified /// position, using a callback to directly initialize array storage by /// populating an output span. @@ -75,7 +75,7 @@ extension RigidArray where Element: ~Copyable { } return result! } - + /// Replaces the specified range of elements by a given count of new items, /// using a callback to directly initialize array storage by populating /// an output span. @@ -228,10 +228,59 @@ extension RigidArray where Element: ~Copyable { ) { self.replace(removing: subrange, moving: &newElements) } + + + /// Perform a range replacement up to populating the newly opened gap. This + /// deinitializes existing elements in the specified subrange, rearranges + /// following elements to be at their final location, and sets the container's + /// new count. + /// + /// - Returns: A buffer pointer addressing the newly opened gap, to be + /// initialized by the caller. + @available(*, deprecated) // FIXME: Obsolete, remove this + @usableFromInline + @unsafe + internal mutating func _gapForReplacement( + of subrange: Range, newItemCount: Int + ) -> UnsafeMutableBufferPointer { + precondition( + subrange.lowerBound >= 0 && subrange.upperBound <= _count, + "Index range out of bounds") + precondition(newItemCount >= 0, "Cannot add a negative number of items") + precondition( + newItemCount - subrange.count <= freeCapacity, + "RigidArray capacity overflow") + unsafe _items.extracting(subrange).deinitialize() + return _resizeGap(in: subrange, to: newItemCount) + } } @available(SwiftStdlib 5.0, *) extension RigidArray { + /// Copy the contents of this array into a newly allocated rigid array + /// instance with just enough capacity to hold all its elements. + /// + /// - Complexity: O(`count`) + @available(*, deprecated, renamed: "clone()") + @inlinable + public func copy() -> Self { + clone() + } + + + /// Copy the contents of this array into a newly allocated rigid array + /// instance with the specified capacity. + /// + /// - Parameter capacity: The desired capacity of the resulting rigid array. + /// `capacity` must be greater than or equal to `count`. + /// + /// - Complexity: O(`count`) + @available(*, deprecated, renamed: "clone(capacity:)") + @inlinable + public func copy(capacity: Int) -> Self { + clone(capacity: capacity) + } + /// Replaces the specified subrange of elements by copying the elements of /// the given buffer pointer, which must be fully initialized. /// diff --git a/Sources/BasicContainers/RigidArray/RigidArray.swift b/Sources/BasicContainers/RigidArray/RigidArray.swift index 9fadb604..2ef88c48 100644 --- a/Sources/BasicContainers/RigidArray/RigidArray.swift +++ b/Sources/BasicContainers/RigidArray/RigidArray.swift @@ -384,29 +384,6 @@ extension RigidArray { result._count = count return result } - - /// Copy the contents of this array into a newly allocated rigid array - /// instance with just enough capacity to hold all its elements. - /// - /// - Complexity: O(`count`) - @available(*, deprecated, renamed: "clone()") - @inlinable - public func copy() -> Self { - clone() - } - - /// Copy the contents of this array into a newly allocated rigid array - /// instance with the specified capacity. - /// - /// - Parameter capacity: The desired capacity of the resulting rigid array. - /// `capacity` must be greater than or equal to `count`. - /// - /// - Complexity: O(`count`) - @available(*, deprecated, renamed: "clone(capacity:)") - @inlinable - public func copy(capacity: Int) -> Self { - clone(capacity: capacity) - } } @@ -470,30 +447,6 @@ extension RigidArray where Element: ~Copyable { uncheckedBounds: (subrange.lowerBound, subrange.lowerBound + newItemCount)) return unsafe _storage.extracting(gapRange) } - - /// Perform a range replacement up to populating the newly opened gap. This - /// deinitializes existing elements in the specified subrange, rearranges - /// following elements to be at their final location, and sets the container's - /// new count. - /// - /// - Returns: A buffer pointer addressing the newly opened gap, to be - /// initialized by the caller. - @available(*, deprecated) // FIXME: Obsolete, remove this - @usableFromInline - @unsafe - internal mutating func _gapForReplacement( - of subrange: Range, newItemCount: Int - ) -> UnsafeMutableBufferPointer { - precondition( - subrange.lowerBound >= 0 && subrange.upperBound <= _count, - "Index range out of bounds") - precondition(newItemCount >= 0, "Cannot add a negative number of items") - precondition( - newItemCount - subrange.count <= freeCapacity, - "RigidArray capacity overflow") - unsafe _items.extracting(subrange).deinitialize() - return _resizeGap(in: subrange, to: newItemCount) - } } #endif diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray+Deprecated.swift b/Sources/BasicContainers/UniqueArray/UniqueArray+Deprecated.swift index bde410a4..bfda4f1c 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray+Deprecated.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray+Deprecated.swift @@ -274,6 +274,29 @@ extension UniqueArray where Element: ~Copyable { @available(SwiftStdlib 5.0, *) extension UniqueArray { + /// Copy the contents of this array into a newly allocated unique array + /// instance with just enough capacity to hold all its elements. + /// + /// - Complexity: O(`count`) + @available(*, deprecated, renamed: "clone()") + @inlinable + public func copy() -> Self { + self.clone() + } + + /// Copy the contents of this array into a newly allocated unique array + /// instance with the specified capacity. + /// + /// - Parameter capacity: The desired capacity of the resulting unique array. + /// `capacity` must be greater than or equal to `count`. + /// + /// - Complexity: O(`count`) + @available(*, deprecated, renamed: "clone(capacity:)") + @inlinable + public func copy(capacity: Int) -> Self { + clone(capacity: capacity) + } + /// Replaces the specified subrange of elements by copying the elements of /// the given buffer pointer, which must be fully initialized. /// diff --git a/Sources/BasicContainers/UniqueArray/UniqueArray.swift b/Sources/BasicContainers/UniqueArray/UniqueArray.swift index 3f99cc7b..17cfaae3 100644 --- a/Sources/BasicContainers/UniqueArray/UniqueArray.swift +++ b/Sources/BasicContainers/UniqueArray/UniqueArray.swift @@ -302,31 +302,5 @@ extension UniqueArray { public func clone(capacity: Int) -> Self { UniqueArray(consuming: _storage.clone(capacity: capacity)) } - - /// Copy the contents of this array into a newly allocated unique array - /// instance with just enough capacity to hold all its elements. - /// - /// - Complexity: O(`count`) - @available(*, deprecated, renamed: "clone()") - @inlinable - public func copy() -> Self { - self.clone() - } - - /// Copy the contents of this array into a newly allocated unique array - /// instance with the specified capacity. - /// - /// - Parameter capacity: The desired capacity of the resulting unique array. - /// `capacity` must be greater than or equal to `count`. - /// - /// - Complexity: O(`count`) - @available(*, deprecated, renamed: "clone(capacity:)") - @inlinable - public func copy(capacity: Int) -> Self { - clone(capacity: capacity) - } } - - - #endif