Expand description
§Learned Partition Sort
A high-performance sorting algorithm that learns data distribution to achieve O(N) complexity on well-distributed numerical data.
§Functions
learned_sort: Fast version using auxiliary buffer (2N memory)learned_sort_inplace: Memory-efficient version (N + O(buckets) memory)
§Example
use learned_partition_sort::{learned_sort, learned_sort_inplace};
// Fast version (uses auxiliary buffer)
let mut data: Vec<i64> = vec![5, 2, 8, 1, 9, 3, 7, 4, 6];
learned_sort(&mut data);
assert_eq!(data, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]);
// Memory-efficient version (for large arrays or constrained environments)
let mut data: Vec<i64> = vec![5, 2, 8, 1, 9, 3, 7, 4, 6];
learned_sort_inplace(&mut data);
assert_eq!(data, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]);Functions§
- learned_
sort - Sorts a slice using the Learned Partition Sort algorithm.
- learned_
sort_ inplace - Sorts a slice using an in-place variant of Learned Partition Sort.