proposal for BTreeMap/Set min/max, #62924#65637
proposal for BTreeMap/Set min/max, #62924#65637bors merged 1 commit intorust-lang:masterfrom ssomers:master
Conversation
|
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
|
Hmm, Slightly crazy idea: |
|
I'm definitely crazy about |
|
Restrain myself? I'll leave that up to others. Let's pop ahead of HashMap users and make BTreeSet even faster than it already is! |
There was a problem hiding this comment.
| /// The first value is always the minmumn value in the set. | |
| /// The first value is always the minimum value in the set. |
|
I noticed that in my 2nd commit, but also in the earliest documentation commit 21ac985, some of the descriptions of BTreeSet mention "element" and some "value" for the thingies contained. I settled on "value" for the new functions because that seems most popular (8 against 6, discarding similar descriptions and those I contributed). Also, a little more proper unit testing (separate from doc tests). |
|
I'm sorry, I haven't had time to review, still expect to do it, but don't mind someone else jumping in. |
|
Here are some arguments for and against the immutable variants:
For and against the mutable variants:
|
|
@Centril can I reassign this? I won't have the time unfortunately |
|
Sure, let's try r? @scottmcm |
|
These seems plausible and the implementations look fine. I think it's ok for them to get checked in, and then libs can decide later if they're worth stabilizing or should be removed. @bors r+ |
|
📌 Commit ffeac1f has been approved by |
proposal for BTreeMap/Set min/max, #62924 - Which pair of names: #62924 lists the existing possibilities min/max, first/last, (EDIT) front/back, peek(/peek_back?). Iterators have next/next_back or next/last. I'm slightly in favour of first/last because min/max might suggest they search over the entire map, and front/back pretends they are only about position. - Return key only instead of pair like iterator does? - If not, then keep the _key_value suffix? ~~Also provide variant with mutable value? But there is no such variant for get_key_value.~~ - Look for and upgrade more usages of `.iter().next()` and such in the libraries? I only upgraded the ones I contributed myself, all very recently.
|
☀️ Test successful - checks-azure |
BTreeMap first last proposal tweaks Clean-up and following up on a request in rust-lang#62924. Trying the reviewer of the original code rust-lang#65637... r? @scottmcm
BTreeMap first last proposal tweaks Clean-up and following up on a request in rust-lang#62924. Trying the reviewer of the original code rust-lang#65637... r? @scottmcm
Also provide variant with mutable value? But there is no such variant for get_key_value..iter().next()and such in the libraries? I only upgraded the ones I contributed myself, all very recently.