It would be great if BTreeMap/BTreeSet were to have a remove_range
method, that, instead of merely removing a single element (as the stable remove
does), could remove all those within a range (similar to how BTree{Map,Set}::range
iterates over those elements).
Right now one would have to use BTree{Map,Set}::retain
with a check like |k, _| !range.contains(k))
to achieve functionally the same behavior -- but that iterates over the entire collection. Range based removal would no longer need to visit the entire collection, as said collection is sorted.
This request is somewhat similar to BTreeMap::drain with a range.