Expand description
Parallel quicksort.
This implementation is copied verbatim from std::slice::sort_unstable
and then parallelized.
The only difference from the original is that calls to recurse
are executed in parallel using
rayon_core::join
.
Structsยง
- Copy
OnDrop ๐When dropped, copies fromsrc
intodest
.
Functionsยง
- break_
patterns ๐Scatters some elements around in an attempt to break patterns that might cause imbalanced partitions in quicksort. - choose_
pivot ๐Chooses a pivot inv
and returns the index andtrue
if the slice is likely already sorted. - heapsort ๐Sorts
v
using heapsort, which guarantees O(n * log(n)) worst-case. - insertion_
sort ๐Sorts a slice using insertion sort, which is O(n^2) worst-case. - par_
quicksort ๐Sortsv
using pattern-defeating quicksort in parallel. - Partially sorts a slice by shifting several out-of-order elements around.
- partition ๐Partitions
v
into elements smaller thanv[pivot]
, followed by elements greater than or equal tov[pivot]
. - partition_
equal ๐Partitionsv
into elements equal tov[pivot]
followed by elements greater thanv[pivot]
. - partition_
in_ ๐blocks Partitionsv
into elements smaller thanpivot
, followed by elements greater than or equal topivot
. - recurse ๐Sorts
v
recursively. - shift_
head ๐Shifts the first element to the right until it encounters a greater or equal element. - shift_
tail ๐Shifts the last element to the left until it encounters a smaller or equal element.