Expand description
Parallel merge sort.
This implementation is copied verbatim from std::slice::sort
and then parallelized.
The only difference from the original is that the sequential mergesort
returns
MergesortResult
and leaves descending arrays intact.
Structs§
- When dropped, copies from
src
intodest
a sequence of lengthlen
. - Run 🔒A sorted run that starts at index
start
and is of lengthlen
.
Enums§
- The result of merge sort.
Functions§
- collapse 🔒Examines the stack of runs and identifies the next pair of runs to merge. More specifically, if
Some(r)
is returned, that meansruns[r]
andruns[r + 1]
must be merged next. If the algorithm should continue building a new run instead,None
is returned. - Inserts
v[0]
into pre-sorted sequencev[1..]
so that wholev[..]
becomes sorted. - merge 🔒 ⚠Merges non-decreasing runs
v[..mid]
andv[mid..]
usingbuf
as temporary storage, and stores the result intov[..]
. - mergesort 🔒 ⚠Sorts a slice using merge sort, unless it is already in descending order.
- par_
merge 🔒 ⚠Merges slicesleft
andright
in parallel and stores the result intodest
. - Sorts
v
using merge sort in parallel. - recurse 🔒 ⚠Recursively merges pre-sorted chunks inside
v
. - Splits two sorted slices so that they can be merged in parallel.