Document iteration order of retain
functions
For `HashSet` and `HashMap`, this simply copies the comment from `BinaryHeap::retain`. For `BTreeSet` and `BTreeMap`, this adds an additional guarantee that wasn't previously documented. I think that because these data structures are inherently ordered and other functions guarantee ordered iteration, it makes sense to provide this guarantee for `retain` as well.
This commit is contained in:
parent
64de4979e8
commit
2dd69aaafc
4 changed files with 4 additions and 0 deletions
|
@ -936,6 +936,7 @@ impl<K, V> BTreeMap<K, V> {
|
|||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
|
||||
/// The elements are visited in ascending key order.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -847,6 +847,7 @@ impl<T> BTreeSet<T> {
|
|||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
||||
/// The elements are visited in ascending order.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -936,6 +936,7 @@ where
|
|||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)` returns `false`.
|
||||
/// The elements are visited in unsorted (and unspecified) order.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
|
@ -914,6 +914,7 @@ where
|
|||
/// Retains only the elements specified by the predicate.
|
||||
///
|
||||
/// In other words, remove all elements `e` such that `f(&e)` returns `false`.
|
||||
/// The elements are visited in unsorted (and unspecified) order.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
Loading…
Add table
Reference in a new issue