Struct rdst::RadixSortBuilder
source · pub struct RadixSortBuilder<'a, T> { /* private fields */ }
Implementations§
source§impl<'a, T> RadixSortBuilder<'a, T>
impl<'a, T> RadixSortBuilder<'a, T>
sourcepub fn with_parallel(self, parallel: bool) -> Self
pub fn with_parallel(self, parallel: bool) -> Self
with_parallel(bool)
controls whether or not multiple algorithms will be allowed
to run in parallel on different threads. This will NOT control whether
multi-threaded algorithms will get used.
If you also want the algorithms chosen to be only single-threaded algorithms,
combine this with with_single_threaded_tuner()
.
use rdst::RadixSort;
let mut data: Vec<usize> = vec![5, 22, 3, 7, 9];
data
.radix_sort_builder()
.with_parallel(false)
.with_single_threaded_tuner()
.sort();
sourcepub fn with_low_mem_tuner(self) -> Self
pub fn with_low_mem_tuner(self) -> Self
with_low_mem_tuner()
configures the sort to use a bunch of algorithms that use less
memory for large inputs than the standard tuning. These algorithms include multi-threaded
algorithms for better performance. In some situations, this tuning will be faster than the
standard tuning, but in general use it will be slightly slower.
use rdst::RadixSort;
let mut data: Vec<usize> = vec![5, 22, 3, 7, 9];
data
.radix_sort_builder()
.with_low_mem_tuner()
.sort();
sourcepub fn with_single_threaded_tuner(self) -> Self
pub fn with_single_threaded_tuner(self) -> Self
with_single_threaded_tuner()
configures the sort to use a tuner which only uses
single-threaded sorting algorithms. This will NOT control whether or not algorithms are
allowed to be run in parallel.
For fully single-threaded operation, combine this with with_parallel(false)
.
use rdst::RadixSort;
let mut data: Vec<usize> = vec![5, 22, 3, 7, 9];
data
.radix_sort_builder()
.with_single_threaded_tuner()
.with_parallel(false)
.sort();
sourcepub fn with_tuner(self, tuner: &'a (dyn Tuner + Send + Sync)) -> Self
pub fn with_tuner(self, tuner: &'a (dyn Tuner + Send + Sync)) -> Self
with_tuner()
allows you to provide your own tuning for which sorting algorithm to use
in a given situation.
use rdst::RadixSort;
use rdst::tuner::{Algorithm, Tuner, TuningParams};
struct MyTuner;
impl Tuner for MyTuner {
fn pick_algorithm(&self, p: &TuningParams, _counts: &[usize]) -> Algorithm {
if p.input_len >= 500_000 {
Algorithm::Ska
} else {
Algorithm::Lsb
}
}
}
let mut data: Vec<usize> = vec![5, 22, 3, 7, 9];
data
.radix_sort_builder()
.with_tuner(&MyTuner {})
.sort();
sourcepub fn sort(self)
pub fn sort(self)
sort()
runs the configured sorting algorithm and consumes the RadixSortBuilder to return
your mutable vec / slice back to you.
use rdst::RadixSort;
let mut data: Vec<usize> = vec![5, 22, 3, 7, 9];
data
.radix_sort_builder()
.with_parallel(false)
.with_single_threaded_tuner()
.sort();
data[0] = 123;