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ยง
- CopyOnDrop ๐When dropped, copies from
src
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 in
v
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 ๐Sorts
v
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 ๐Partitions
v
into elements equal tov[pivot]
followed by elements greater thanv[pivot]
. - partition_in_blocks ๐Partitions
v
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.