Struct rdst::RadixSortBuilder

source ·
pub struct RadixSortBuilder<'a, T> { /* private fields */ }

Implementations§

source§

impl<'a, T> RadixSortBuilder<'a, T>
where T: RadixKey + Copy + Send + Sync,

source

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();
source

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();
source

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();
source

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();
source

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;

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for RadixSortBuilder<'a, T>

§

impl<'a, T> Send for RadixSortBuilder<'a, T>
where T: Send,

§

impl<'a, T> Sync for RadixSortBuilder<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for RadixSortBuilder<'a, T>

§

impl<'a, T> !UnwindSafe for RadixSortBuilder<'a, T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.