Uh oh!
There was an error while loading. Please reload this page.
implement sort for VecDeque - #69400
Conversation
rust-highfive
commented
Feb 23, 2020
r? @KodrAus (rust_highfive has picked a reviewer for you, use r? to override) |
An alternative implementation may not need one continuous slice. This could be prevented by changing the deque to not be continuous after sorting: pubfnsort_by<F>(&mutself,compare:F)whereF:FnMut(&T,&T) -> Ordering,{self.make_continuous();self.as_mut_slices().0.sort_by(compare);ifself.len() % 3 == 1{self.make_noncontinuous();}} |
0d50d93 to
9f43c18CompareI temporarily added I think that it would be easiest to move |
rust-highfive
commented
Feb 23, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
rust-highfive
commented
Feb 23, 2020
The job Click to expand the log.I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I experimented with first sorting the two slices and then merging them instead of one continuous sort. Not quite sure on how compare the performance of both implementations before this PR is merged, as I can't easily implement the sorting done in this PR outside of liballoc. See https://github.com/lcnr/vecdeque My current merge is also still broken and needs |
This makes me wonder if |
lcnr
commented
Mar 8, 2020
superseded by #69425 |
KodrAus
commented
Mar 11, 2020
I would personally still be in favour of sorting methods on |
lcnr
commented
Mar 11, 2020
By using I don't think that adding 7 more methods to |
add fn make_contiguous to VecDeque Adds the following method to VecDeque: ```rust pub fn make_contiguous(&mut self) -> &mut [T]; ``` Taken from rust-lang#69400, after a suggestion by @CryZerust-lang#69400 (comment) I am in favor of merging this instead of rust-lang#69400.
closes#27322.
I have currently only implemented
sort_by. If this change is desired,I will gladly add the other sort methods:
sortsort_by_key,sort_by_cached_keysort_unstablesort_unstable_bysort_unstable_by_key