Rust bindings for Google's Highway vectorized quicksort.
The vectorized quicksort sorting algorithm is very fast, as demonstrated in a
writeup,
and outperforms the standard Rust sort_unstable. However, it only supports
primitive integer and floating-point types, as well as key-value tuples.
Supported types:
i16,u16i32,u32i64,u64isize,usizeu128f32,f64Key64Value64,Key32Value32
let mut data = [5, 3, 8, 0, -100];
vqsort_rs::sort(&mut data);
assert_eq!(data, [-100, 0, 3, 5, 8]);
vqsort_rs::sort_descending(&mut data);
assert_eq!(data, [8, 5, 3, 0, -100]);use vqsort_rs::Key32Value32; // or Key64Value64
let mut data = [
Key32Value32 { value: 0, key: 5 },
Key32Value32 { value: 1, key: 3 },
Key32Value32 { value: 2, key: 8 },
Key32Value32 { value: 3, key: 0 },
];
vqsort_rs::sort(&mut data);
assert_eq!(
data,
[
Key32Value32 { value: 3, key: 0 },
Key32Value32 { value: 1, key: 3 },
Key32Value32 { value: 0, key: 5 },
Key32Value32 { value: 2, key: 8 },
]
);
vqsort_rs::sort_descending(&mut data);
assert_eq!(
data,
[
Key32Value32 { value: 2, key: 8 },
Key32Value32 { value: 0, key: 5 },
Key32Value32 { value: 1, key: 3 },
Key32Value32 { value: 3, key: 0 },
]
);When testing under Miri, this crate falls back to sort_unstable because Miri
does not support FFI.