learned_partition_sort/lib.rs
1//! # Learned Partition Sort
2//!
3//! A high-performance sorting algorithm that learns data distribution
4//! to achieve O(N) complexity on well-distributed numerical data.
5//!
6//! ## Functions
7//!
8//! - [`learned_sort`]: Fast version using auxiliary buffer (2N memory)
9//! - [`learned_sort_inplace`]: Memory-efficient version (N + O(buckets) memory)
10//!
11//! ## Example
12//!
13//! ```rust
14//! use learned_partition_sort::{learned_sort, learned_sort_inplace};
15//!
16//! // Fast version (uses auxiliary buffer)
17//! let mut data: Vec<i64> = vec![5, 2, 8, 1, 9, 3, 7, 4, 6];
18//! learned_sort(&mut data);
19//! assert_eq!(data, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]);
20//!
21//! // Memory-efficient version (for large arrays or constrained environments)
22//! let mut data: Vec<i64> = vec![5, 2, 8, 1, 9, 3, 7, 4, 6];
23//! learned_sort_inplace(&mut data);
24//! assert_eq!(data, vec![1, 2, 3, 4, 5, 6, 7, 8, 9]);
25//! ```
26
27mod learned_sort;
28
29pub use learned_sort::{learned_sort, learned_sort_inplace};