[−][src]Function triple_accel::hamming::hamming_words_64
pub fn hamming_words_64(a: &[u8], b: &[u8]) -> u32
Returns the hamming distance between two strings by efficiently counting mismatches in chunks of 64 bits.
The length of a
and b
must be the same.
Both a
and b
must be aligned and padded so they can be directly casted to chunks of u64
.
Use alloc_str
to create aligned and padded strings.
This should be faster than hamming_naive
and maybe even hamming_words_128
. This should be slower
than hamming_simd_parallel/movemask
.
Arguments
a
- first string (slice)b
- second string (slice)
Panics
- If the length of
a
does not equal the length ofb
.
Example
let mut a = alloc_str(3); let mut b = alloc_str(3); fill_str(&mut a, b"abc"); fill_str(&mut b, b"abd"); let dist = hamming_words_64(&a, &b); assert!(dist == 1);