BTreeMap: comment why drain_filter's size_hint is somewhat pessimistictid
This commit is contained in:
parent
90c8b43bc3
commit
3b051d0171
|
@ -1748,6 +1748,10 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
|
||||||
|
|
||||||
/// Implementation of a typical `DrainFilter::size_hint` method.
|
/// Implementation of a typical `DrainFilter::size_hint` method.
|
||||||
pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
|
pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
// In most of the btree iterators, `self.length` is the number of elements
|
||||||
|
// yet to be visited. Here, it includes elements that were visited and that
|
||||||
|
// the predicate decided not to drain. Making this upper bound more accurate
|
||||||
|
// requires maintaining an extra field and is not worth while.
|
||||||
(0, Some(*self.length))
|
(0, Some(*self.length))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue