Skip to main content

Crate learned_partition_sort

Crate learned_partition_sort 

Source
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

§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.