๐ฌ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.
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
index
is at its final sorted position. - partition_
at_ ๐index_ loop Experimental