Navigation Menu

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-1431] Unify the collection capacity APIs #44040

Closed
benrimmington opened this issue May 6, 2016 · 3 comments
Closed

[SR-1431] Unify the collection capacity APIs #44040

benrimmington opened this issue May 6, 2016 · 3 comments
Labels
improvement standard library Area: Standard library umbrella

Comments

@benrimmington
Copy link
Collaborator

Previous ID SR-1431
Radar None
Original Reporter @benrimmington
Type Improvement
Status Closed
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Improvement
Assignee None
Priority Medium

md5: 23bbe33713387882bd799456a9754925

Issue Description:

// Array, ArraySlice, ContiguousArray:
public var capacity: Int

// Dictionary, Set:
public init(minimumCapacity: Int)

// Dictionary, Set, RangeReplaceableCollection:
public mutating func removeAll(keepingCapacity keepCapacity: Bool = false)

// RangeReplaceableCollection:
public mutating func reserveCapacity(_ minimumCapacity: Int)

Is it possible to support all of the above APIs in:

  • Arrays.swift.gyb (Array, ArraySlice, ContiguousArray)

  • HashedCollections.swift.gyb (Dictionary, Set)

  • StringCharacterView.swift

  • StringUnicodeScalarView.swift

For example, it might be useful to get/set the capacity of a dictionary.

Currently, only the `removeAll` method is common to all types.

@belkadan
Copy link
Contributor

belkadan commented May 6, 2016

I'm not sure what the action item is here. Dictionary and Set behave differently from Array and other RangeReplaceableCollections.

@benrimmington
Copy link
Collaborator Author

Sorry, I didn't explain properly. I've updated the description.

@benrimmington
Copy link
Collaborator Author

This issue should be discussed on the swift-evolution mailing list.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants