New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimum/maximum elements search in BTreeMap/BTreeSet #31690
Comments
A dedicated method would improve discoverability, but you can do: let map: BTreeMap<K, V> = ...;
let min = map.iter().next();
let max = map.iter().next_back(); and the same for |
Hm, I haven't known about |
BTW, I don't see a mention in the documentation that |
Some thoughts on the matter: if |
It does do the right thing. |
Thanks! I guess this is purely a documentation issue then. What about changing Gets an iterator over the BTreeMap's contents, ordered ascending by its keys. Complexity of first call to (Sorry for possibly bad language, I'm bad at writing documentation) |
Closing this in favor of a new range RFC. |
It would be nice to have something like (pseudo-code):
This should be fast for trees (just walk the tree to the left-most or right-most element) and is very useful. For example Haskell has these functions in its excellent library containers, along with other potentially interesting functions (see the whole "Min/Max" section).
The text was updated successfully, but these errors were encountered: