Clarify `endIndex` behavior of `partitioningIndex(where:)` in documentation
mdznr opened this issue · 0 comments
swift-algorithms/Sources/Algorithms/Partition.swift
Lines 171 to 182 in e2fa131
In the documentation for partitioningIndex(where:)
, it only mentions what happens when the predicate returns true
. But, if the predicate
returns false
in all cases, it is unclear what the return value is. The documentation should be written so that it is clear that the return value is endIndex
if belongsInSecondPartition
returns false
for all elements.
I think this should at least be reflected in the “Returns” section of the inline documentation, but could probably be made more clear by rephrasing the first few sentences. The first sentence makes it sound like this is identical to firstIndex(where:)
, but the second and third sentences make the behavior more clear, indicating that this function is only to be used on collections that have already been partitioned.