diff --git a/src/lib.rs b/src/lib.rs index a4edb0d..a2629b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ use std::cmp::Ordering; -pub fn partition_by Ordering> +fn partition_by Ordering> (slice: &mut [T], start: isize, end: isize, compare: &mut F) -> isize { let mut i = start; @@ -15,7 +15,7 @@ pub fn partition_by Ordering> } -pub fn quick_sort_by Ordering> +fn quick_sort_by Ordering> (slice: &mut [T], start: isize, end: isize, compare: &mut F) { if start < end { @@ -27,7 +27,7 @@ pub fn quick_sort_by Ordering> } pub fn partial_sort_by Ordering> -(slice: &mut [T], k: isize, compare: &mut F) { +(slice: &mut [T], k: usize, compare: &mut F) { let mut start = 0; let mut end = slice.len() as isize - 1; @@ -37,7 +37,7 @@ pub fn partial_sort_by Ordering> let index = partition_by(slice, start, end, compare); let rank = index + 1; - if rank >= k { + if rank >= k as isize { end = index - 1; } else if index - start > end - index { quick_sort_by(slice, index + 1, end, compare); @@ -64,11 +64,11 @@ pub fn partial_sort_by Ordering> /// /// The implementation is based on [this gist](https://gist.github.com/mesuvash/4095565). pub fn partial_sort(slice: &mut [T], k: usize) { - partial_sort_by(slice, k as isize, &mut |x, y| x.cmp(y)); + partial_sort_by(slice, k, &mut |x, y| x.cmp(y)); } pub fn partial_sort_by_key O>(slice: &mut [T], k: usize, key: &mut F) { - partial_sort_by(slice, k as isize, &mut |x, y| key(x).cmp(&key(y))); + partial_sort_by(slice, k, &mut |x, y| key(x).cmp(&key(y))); } #[cfg(test)]