Skip to content

Clarify endIndex behavior of partitioningIndex(where:) in documentation (Resolves #170) #171

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

Merged
merged 4 commits into from
Dec 16, 2021

Conversation

mdznr
Copy link
Contributor

@mdznr mdznr commented Oct 23, 2021

Resolves #170

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

///
/// The collection must already be partitioned according to the predicate.
/// That is, there should be an index `i` where for every element in
/// `collection[..<i]` the predicate is `false`, and for every element in
/// `collection[i...]` the predicate is `true`.
///
/// - Parameter belongsInSecondPartition: A predicate that partitions the
/// collection.
/// - Returns: The index of the first element in the collection for which
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’m still a bit unsure about this sentence. It almost sounds like the first time that predicate is evaluated and returns true, execution stops and that index is returned, like firstIndex(where:).

@mdznr mdznr force-pushed the 170_partitioningIndex_documentation branch from bdb7c7f to b19be16 Compare December 3, 2021 17:09
@natecook1000
Copy link
Member

@swift-ci Please test

The returned index isn’t necessarily an index of an element. In the case where it returns `endIndex`, it’s not valid for subscripting the collection.

Resolves apple#170
…llection belong in one of the two partitions
@mdznr mdznr force-pushed the 170_partitioningIndex_documentation branch from b19be16 to dd5a49b Compare December 14, 2021 16:21
@natecook1000
Copy link
Member

@swift-ci Please test

@natecook1000 natecook1000 merged commit da475ea into apple:main Dec 16, 2021
@mdznr mdznr deleted the 170_partitioningIndex_documentation branch June 16, 2023 21:00
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.

Clarify endIndex behavior of partitioningIndex(where:) in documentation
3 participants