Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcroomp committed Nov 21, 2023
1 parent c78edc2 commit b02890e
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/huffman_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,7 @@ fn is_valid_huffman_code_lengths(code_lengths: &[u8]) -> bool {
length_count[length as usize] += 1;
}

let h = HashSet::<_>::from_iter(
code_lengths
.iter()
.map(|&x| usize::from(x))
.filter(|&x| x != 0),
);

// Validate the code lengths
for length in h {
if length_count[length] > 0 {
length_count[length] -= 1;
for i in 1..length {
if length_count[i] < length_count[length] {
return false;
}
length_count[i] -= length_count[length];
}
} else {
return false;
}
}
// todo - check for invalid code lengths

true
}
Expand Down

0 comments on commit b02890e

Please sign in to comment.