From cbff0068adae83385139014c5b9141df3c6e08ff Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 9 Jul 2018 16:54:31 +0200 Subject: [PATCH] Removed public functions, public functions take usize --- src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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)]