Skip to content

[Stdlib] Add notes to lazy collection doc comments about complexity #829

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

Conversation

lilyball
Copy link
Contributor

Many lazy collections don't offer O(1) performance for startIndex,
first, or any method that depends on startIndex.
LazyFilterCollection already had a note to this effect (which I
tweaked a bit), but FlattenCollection didn't, and I added one to
LazyCollectionType for good measure.

Related to SR-425.

/// - Note: Many lazy collections may not offer the usual performance given by
/// `CollectionType`, `ForwardIndexType`, or `BidirectionalIndexType`. Be
/// aware, therefore, that general operations on `LazyCollectionType`
/// instances may not have the documented complexity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this note; we have one instance of LazyCollectionType that’s like this, and one other collection that has this behavior and "is lazy” but is-not-a LazyCollectionType, so the note doesn’t belong here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I put it here because I figured any newly-added lazy collections have a decent chance of also having unpredictable performance, but you're right, with only one actual instance of a LazyCollectionType with that performance, it's probably not worth having this note here.

Many lazy collections don't offer O(1) performance for `startIndex`,
`first`, or any method that depends on `startIndex`.
`LazyFilterCollection` already had a note to this effect (which I
tweaked a bit), but `FlattenCollection` didn't.

Related to SR-425.
@lilyball lilyball force-pushed the add-complexity-caveats-to-lazy-collections branch from 9edcca0 to dee1c7a Compare December 31, 2015 21:36
@lilyball
Copy link
Contributor Author

@dabrahams: Updated as per feedback.

dabrahams pushed a commit that referenced this pull request Dec 31, 2015
…collections

[Stdlib] Add notes to lazy collection doc comments about complexity
@dabrahams dabrahams merged commit 09b6afc into swiftlang:master Dec 31, 2015
@lilyball lilyball deleted the add-complexity-caveats-to-lazy-collections branch January 1, 2016 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants