Skip to content

Commit

Permalink
refactor: Update 'is_unordered' to return early when first instance i…
Browse files Browse the repository at this point in the history
…s found (#93)
  • Loading branch information
lsetiawan authored Dec 20, 2024
1 parent c2cd7e6 commit 7a42bf7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions phylo2vec/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,14 @@ fn _check_max(idx: usize, value: usize) -> () {
/// assert_eq!(unordered, false);
/// ```
pub fn is_unordered(v: &Vec<usize>) -> bool {
let mut unordered = false;
for i in 0..v.len() {
_check_max(i, v[i]);
if v[i] > i + 1 {
unordered = true;
return true;
}
}

unordered
false
}

#[cfg(test)]
Expand Down

0 comments on commit 7a42bf7

Please sign in to comment.