]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #68770 - ssomers:btree_drain_filter, r=Amanieu
authorDylan DPC <dylan.dpc@gmail.com>
Tue, 31 Mar 2020 22:27:18 +0000 (00:27 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2020 22:27:18 +0000 (00:27 +0200)
BTreeMap/BTreeSet: implement drain_filter

Provide an implementation of drain_filter for BTreeMap and BTreeSet. Should be optimal when the predicate picks only elements in leaf nodes with at least MIN_LEN remaining elements, which is a common case, at least when draining only a fraction of the map/set, and also when the predicate picks elements stored in internal nodes where the right subtree can easily let go of a replacement element.

The first commit adds benchmarks with an external, naive implementation. to compare how much this claimed optimality-in-some-cases is actually worth.

1  2 
src/liballoc/tests/btree/map.rs

Simple merge