Open ghost opened 1 year ago
So you want an optimized drop_while
where the range
is_partitioned
on the predicate.
Actually my request holds for take_while and filter as well.
Range may be partitioned or not. But always sorted in regard to the criteria.
Do you mean you would pass an argument telling it if the range is sorted? Otherwise, determining if the range is sorted would require iterating over every element anyway.
Yes a boolean, Or a ::ranges::views::already_sorted flag.. like so
auto v = my_container | ::ranges::views::already_sorted | the rest
At this point, the dev takes the responsibility of this criteria and that the following drop_while/take_while/filter uses are coherent with this flag. otherwise, don't use this flag, and do just like right now.
It is just a speed optimization opportunity that may be used or not.
Hi, Reading drop_while page I think it would be handy to be able to tell that we are iterating an already sorted range, when applicable.
Right now, it seems to iterate every elements, whereas it could use a binary search to go faster.