Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-3027] add Array.init(minimumCapacity: Int) #45617

Closed
krzyzanowskim opened this issue Oct 23, 2016 · 1 comment
Closed

[SR-3027] add Array.init(minimumCapacity: Int) #45617

krzyzanowskim opened this issue Oct 23, 2016 · 1 comment
Labels
duplicate Resolution: Duplicates another issue feature A feature request or implementation standard library Area: Standard library umbrella swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-3027
Radar None
Original Reporter @krzyzanowskim
Type New Feature
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: d556fbb29aa1b408f5119b1b265e25ca

duplicates:

  • SR-2909 Array should have an initializer that reserves capacity

Issue Description:

Array and RangeReplaceableCollection has declared function reserveCapacity()

mutating func reserveCapacity(_:) { ... }

and there is no initializer that allows get Array with reserverCapacity, like

init(minimumCapacity: Int)

therefore to get empty array with reserved capacity I have to do

var arr = Array<Int>()
arr.reserveCapacity(500)

that looks like unecessary. What if we have convenient initializer with minimum capacity parameter so empty array capacity don't have to be reallocated after allocation.

@Dante-Broggi
Copy link
Contributor

Marking the newer (this one) as the duplicate.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added duplicate Resolution: Duplicates another issue swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented and removed new feature labels Nov 10, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Resolution: Duplicates another issue feature A feature request or implementation standard library Area: Standard library umbrella swift evolution implemented Flag → feature: A feature that was approved through the Swift evolution process and implemented
Projects
None yet
Development

No branches or pull requests

3 participants