RigidArray, UniqueArray: Move remaining deprecations to dedicated file

This commit is contained in:
Karoy Lorentey committed 2026-02-05 16:46:14 -08:00
1 parent e6d6731124
commit b9fd3ed56e
4 files changed
+74 -75

No files matched your search

@@ -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<Int>, newItemCount: Int
) -> UnsafeMutableBufferPointer<Element> {
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.
///
@@ -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<Int>, newItemCount: Int
) -> UnsafeMutableBufferPointer<Element> {
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
@@ -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.
///
@@ -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