mirror of
https://github.com/apple/swift-collections
synced 2026-11-27 04:54:21 +00:00
Rename reallocate to setCapacity for Rigid and UniqueArray
Update UniqueArray.swift Update UniqueArray.swift
This commit is contained in:
1 parent
af174fe447
commit
6da58357a3
6 files changed
+101
-7
No files matched your search
@@ -87,6 +87,23 @@ extension UniqueArray where Element: ~Copyable {
|
||||
return result!
|
||||
}
|
||||
|
||||
/// Grow or shrink the capacity of a unique array instance without discarding
|
||||
/// its contents.
|
||||
///
|
||||
/// This operation replaces the array's storage buffer with a newly allocated
|
||||
/// buffer of the specified capacity, moving all existing elements
|
||||
/// to its new storage. The old storage is then deallocated.
|
||||
///
|
||||
/// - Parameter newCapacity: The desired new capacity. `newCapacity` must be
|
||||
/// greater than or equal to the current count.
|
||||
///
|
||||
/// - Complexity: O(`count`)
|
||||
@available(*, deprecated, renamed: "setCapacity(_:)")
|
||||
@inlinable
|
||||
public mutating func reallocate(capacity: Int) {
|
||||
_storage.reallocate(capacity: capacity)
|
||||
}
|
||||
|
||||
/// 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.
|
||||
|
||||
@@ -259,8 +259,8 @@ extension UniqueArray where Element: ~Copyable {
|
||||
///
|
||||
/// - Complexity: O(`count`)
|
||||
@inlinable
|
||||
public mutating func reallocate(capacity: Int) {
|
||||
_storage.reallocate(capacity: capacity)
|
||||
public mutating func setCapacity(_ newCapacity: Int) {
|
||||
_storage.setCapacity(newCapacity)
|
||||
}
|
||||
|
||||
/// Ensure that the array has capacity to store the specified number of
|
||||
|
||||
Reference in new issue
Block a user