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-7785] Complexity of dropFirst/dropLast on RandomAccessCollection #50324

Open
martinr448 opened this issue May 26, 2018 · 0 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. documentation standard library Area: Standard library umbrella

Comments

@martinr448
Copy link

Previous ID SR-7785
Radar None
Original Reporter @martinr448
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, Documentation
Assignee None
Priority Medium

md5: cd47f573c0e3209654ce7041b06b2c8a

Issue Description:

The documentation is wrong about of the complexity of dropFirst/dropLast for the Array type:

dropFirst(_:)
// Complexity: O(n), where n is the number of elements to drop from the beginning of the collection.

dropLast()
// Complexity: O(n), where n is the length of the sequence.

dropLast(_:)
// Complexity: O(n), where n is the number of elements to drop.

For arrays (or generally for RandomAccessCollection) the complexity is O(1), independent of the collection size or the number of elements to drop.

Related discussion in the Swift Forum: dropLast() vs. dropLast(1) for arrays

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. documentation standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

1 participant