-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
paper cut: is a slice / Iterator sorted? #44370
Copy link
Copy link
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-feature-acceptedCategory: A feature request that has been accepted pending implementation.Category: A feature request that has been accepted pending implementation.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I just used
binary_searchinside a loop and realized that it would be nice to check before the loop if my immutable slice was sorted. So I spent 10 minutes going through the standard library just to find out that there aren't anyis_sorted,is_sorted_by,is_sorted_by_key, etc. algorithms implemented for neither slices nor iterators.We should add:
Iterator::is_sortedIterator::is_sorted_byIterator::is_sorted_by_keyand since
Iteratoris implemented for slices, we can add those methods to slices as well by just forwarding to theIteratorimplementation.