๐ฌThis is a nightly-only experimental API. (
slice_internals)Expand description
This module contains the implementation for slice::select_nth_unstable.
It uses an introselect algorithm based on ipnsort by Lukas Bergdoll and Orson Peters,
published at: https://github.com/Voultapher/sort-research-rs/tree/main/ipnsort
The fallback algorithm used for introselect is Median of Medians using Tukeyโs Ninther for pivot selection. Using this as a fallback ensures O(n) worst case running time with better performance than one would get using heapsort as fallback.
Re-exportsยง
use crate::cfg_select;๐use crate::mem;๐use crate::mem::SizedTypeProperties;๐Experimental use crate::slice::sort::shared::pivot::choose_pivot;๐Experimental Non- optimize_for_sizeuse crate::slice::sort::shared::smallsort::insertion_sort_shift_left;๐Experimental use crate::slice::sort::unstable::quicksort::partition;๐Experimental
Constantsยง
- INSERTION_
SORT_ ๐THRESHOLD Experimental
Functionsยง
- max_
index ๐Experimental - Helper function that returns the index of the maximum element in the slice using the given comparator function
- median_
idx ๐Experimental - returns the index pointing to the median of the 3
elements
v[a],v[b]andv[c] - median_
of_ ๐medians Experimental - Selection algorithm to select the k-th element from the slice in guaranteed O(n) time. This is essentially a quickselect that uses Tukeyโs Ninther for pivot selection
- median_
of_ ๐ninthers Experimental - min_
index ๐Experimental - Helper function that returns the index of the minimum element in the slice using the given comparator function
- ninther ๐
Experimental - Moves around the 9 elements at the indices a..i, such that
v[d]contains the median of the 9 elements and the other elements are partitioned around it. - partition_
at_ ๐index Experimental - Reorders the slice such that the element at
indexis at its final sorted position. - partition_
at_ ๐index_ loop Experimental Non- optimize_for_size