-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
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-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]
Description
Activity
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-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]
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.