mirror of
https://github.com/apple/swift-algorithms
synced 2026-11-27 04:34:21 +00:00
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.
This commit is contained in:
1 parent
19c1d00177
commit
da475ea9af
2 files changed
+24
-3
No files matched your search
@@ -168,8 +168,8 @@ extension MutableCollection where Self: BidirectionalCollection {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
extension Collection {
|
||||
/// Returns the index of the first element in the collection that matches
|
||||
/// the predicate.
|
||||
/// Returns the start index of the partition of a collection that matches
|
||||
/// the given predicate.
|
||||
///
|
||||
/// The collection must already be partitioned according to the predicate.
|
||||
/// That is, there should be an index `i` where for every element in
|
||||
@@ -179,7 +179,8 @@ extension Collection {
|
||||
/// - Parameter belongsInSecondPartition: A predicate that partitions the
|
||||
/// collection.
|
||||
/// - Returns: The index of the first element in the collection for which
|
||||
/// `predicate` returns `true`.
|
||||
/// `predicate` returns `true`, or `endIndex` if there are no elements
|
||||
/// for which `predicate` returns `true`.
|
||||
///
|
||||
/// - Complexity: O(log *n*), where *n* is the length of this collection if
|
||||
/// the collection conforms to `RandomAccessCollection`, otherwise O(*n*).
|
||||
|
||||
Reference in new issue
Block a user