-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for slice_partition_at_index #55300
Comments
Just for the record, if someone needs this functionality right now, the order_stat crate provides an implementation of the Floyd-Rivest selection algorithm. |
Add 'partition_at_index/_by/_by_key' for slices. This is an analog to C++'s std::nth_element (a.k.a. quickselect). Corresponds to tracking bug rust-lang#55300.
Add 'partition_at_index/_by/_by_key' for slices. This is an analog to C++'s std::nth_element (a.k.a. quickselect). Corresponds to tracking bug #55300.
A thought: since we have |
Add 'partition_at_index/_by/_by_key' for slices. This is an analog to C++'s std::nth_element (a.k.a. quickselect). Corresponds to tracking bug rust-lang#55300.
Add 'partition_at_index/_by/_by_key' for slices. This is an analog to C++'s std::nth_element (a.k.a. quickselect). Corresponds to tracking bug rust-lang#55300.
Hi @Mokosha , is this expected to be stabilized eventually? |
@umanwizard I have no idea what the standardization process is for features, so I don't really know how to answer that. Happy to support whatever needs to be done for that though! |
APIs currently pointing here below. These seem very niche to me. @rust-lang/libs any thoughts? impl<T> [T] {
pub fn partition_at_index(&mut self, index: usize) -> (&mut [T], &mut T, &mut [T])
where T: Ord
{…}
pub fn partition_at_index_by<F>(&mut self, index: usize, mut compare: F)
-> (&mut [T], &mut T, &mut [T])
where F: FnMut(&T, &T) -> Ordering
{…}
pub fn partition_at_index_by_key<K, F>(&mut self, index: usize, mut f: F)
-> (&mut [T], &mut T, &mut [T])
where F: FnMut(&T) -> K, K: Ord
{…}
} |
The naming here threw me for a spin and once I got around to reading the documentation this does seems something standard-library-ish but I agree it's pretty niche. On naming |
I think "doing a sort and ..." is at best a very misleading description. Every element is guaranteed to end up on the correct side of the Do you know of any other term for this? I've only ever heard this operation referred to as (but I agree with s/ |
This isn't C++'s If so I think it's an excellent thing to have in the library, especially since the complicated parts of the implementation are things that (Interestingly, note that this method is actually an answer to an exercise in the book.) As for naming, I'm not super fond of the current one, but unfortunately don't have any good suggestions. |
Yes, this is closer to C++'s With regards to the naming -- there were some alternatives to With the attention of the libs team, though, provided the procedure outlined here is still followed, what else needs to be done for stabilization? |
FWIW, this was confusing to me at quick glance because in python |
I'm fine with (Sorry if I necro'ed this and everything is already decided. Just my 2 cents...) |
These algorithms (what C++ I agree that these functions in Rust are called |
I'd like to "push for stabilization", as per the stabilization guide. These functions are very useful for building various types of spatial indices (RTrees, KDTrees, etc), for which you need to repeatedly partition, but not sort. From reading the comments, it seems only the name is still under discussion. Is that true? If so how do we drive that to completion? Are there other concerns? If there aren't, then I can start the Documentation PR and writing a stabilization report (probably with some oversight and feedback!). |
The main issue that that for consistency with |
Team member @Amanieu has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Ok, but...: the name used in C++, So I don't like the name |
Are you in favor of the I think the unfortunate reality is that there is no good name for this particular function -- each candidate has its flaws. Over the last 2 years no one has found a name that is universally liked, so we may have to go with the least objectionable choice. |
I agree with this observation, but as @jagill pointed out, no name that would fulfill this criterion has been proposed so far.
|
What about something like |
I'm on board with |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Was something with Similar functions (not exactly the same, but close enough) are named |
I don't think we can do much better than |
@Amanieu I'm happy to make the PR changing the name and stabilizing the issue, but I have a question: If we change the name, this will be breaking for anyone who's been using the current name. It this acceptable, or is there an aliasing step that will preserve behavior for those using the feature flag? |
@jagill It's nightly so it's allowed, but to make it a bit easier on nightly users it's generally preferable to to stabilize it under a different feature gate name so the old method can be left there for a month or two before being removing. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
…_index, r=Amanieu Stabilize slice_partition_at_index This stabilizes slice_partition_at_index, including renaming `partition_at_index*` -> `select_nth_unstable*`. Closes rust-lang#55300 r? @Amanieu
…ndex, r=Amanieu Stabilize slice_partition_at_index This stabilizes slice_partition_at_index, including renaming `partition_at_index*` -> `select_nth_unstable*`. Closes rust-lang#55300 r? `@Amanieu`
I've opened #93480 to remove the deprecated and unstable |
This is the tracking bug for the discussion outlined in rust-lang/rfcs#1470.
I'm working on implementing this in the
libstd
, and will add it as an unstable feature pending resolution of any comments that may arise in this thread. I plan to add comprehensive testing as well.The text was updated successfully, but these errors were encountered: