make compare and swap functions public

This commit is contained in:
jacekpoz 2024-04-11 04:58:19 +02:00
parent ad9f69de9d
commit 14d2966b51
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -15,11 +15,11 @@ pub fn print_list(list: &[u64]) {
} }
#[derive(PartialEq)] #[derive(PartialEq)]
enum CompareResult { pub enum CompareResult {
LESS, EQUAL, GREATER LESS, EQUAL, GREATER
} }
fn compare(a: u64, b: u64, comparisons: &mut u64) -> CompareResult { pub fn compare(a: u64, b: u64, comparisons: &mut u64) -> CompareResult {
*comparisons += 1; *comparisons += 1;
if a < b { if a < b {
CompareResult::LESS CompareResult::LESS
@ -30,7 +30,7 @@ fn compare(a: u64, b: u64, comparisons: &mut u64) -> CompareResult {
} }
} }
fn swap(list: &mut [u64], i: usize, j: usize, swaps: &mut u64) { pub fn swap(list: &mut [u64], i: usize, j: usize, swaps: &mut u64) {
*swaps += 1; *swaps += 1;
list.swap(i, j); list.swap(i, j);
} }