Fix formatting.

This commit is contained in:
Jesse Brault 2024-11-23 07:18:58 -06:00
parent 749bd0e2bc
commit ce974b30c1
2 changed files with 8 additions and 5 deletions

View File

@ -1,12 +1,12 @@
mod bst;
mod stack;
mod sort;
mod stack;
use bst::BinarySearchTree;
use clap::{Args, Parser, Subcommand};
use rand::Rng;
use bst::BinarySearchTree;
use stack::Stack;
use sort::bucket_sort;
use stack::Stack;
#[derive(Parser, Debug)]
struct Cli {

View File

@ -4,7 +4,10 @@ pub fn bucket_sort<T: Ord + Default + Copy, const SIZE: usize>(to_sort: &[T; SIZ
// sort into buckets
let mut buckets = BTreeMap::new();
for item in to_sort {
buckets.entry(item).and_modify(|count| *count += 1).or_insert(1);
buckets
.entry(item)
.and_modify(|count| *count += 1)
.or_insert(1);
}
// Create new array, copying items to new array
@ -19,4 +22,4 @@ pub fn bucket_sort<T: Ord + Default + Copy, const SIZE: usize>(to_sort: &[T; SIZ
}
}
result
}
}