Skip to content

Commit

Permalink
修改selection_sort和utils的泛型签名
Browse files Browse the repository at this point in the history
  • Loading branch information
donjuanplatinum committed Jun 9, 2024
1 parent e622f13 commit 003d758
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/sorting/selection_sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
/// selection_sort(&mut a,|a,b| a <= b);
/// is_sorted(&mut a,|a,b| a<=b);
/// ```
pub fn selection_sort<T>(array: &mut [T], comparator: fn(&T, &T) -> bool) -> ()
where
T: PartialOrd,
{
pub fn selection_sort<T>(array: &mut [T], comparator: fn(&T, &T) -> bool) -> () {
for point in 0..array.len() {
let mut better: usize = point;
for index in point..array.len() {
Expand Down
5 changes: 1 addition & 4 deletions src/sorting/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
/// insertion_sort(&mut a,|a,b| a <=b);
/// assert_eq!(is_sorted(&mut a,|a,b|a<=b),true);
/// ```
pub fn is_sorted<'a, T>(array: &'a [T], compare: fn(&T, &T) -> bool) -> bool
where
T: PartialOrd + 'a,
{
pub fn is_sorted<'a, T>(array: &'a [T], compare: fn(&T, &T) -> bool) -> bool {
if array.len() == 0 {
return true;
}
Expand Down

0 comments on commit 003d758

Please sign in to comment.