Expand description
A crate to count ones and xor bytes, fast (aka popcount, hamming weight and hamming distance).
§Installation
Add this to your Cargo.toml:
[dependencies]
hamming = "0.1"§Examples
assert_eq!(hamming::weight(&[1, 0xFF, 1, 0xFF]), 1 + 8 + 1 + 8);
assert_eq!(hamming::distance(&[1, 0xFF], &[0xFF, 1]), 7 + 7);Functions§
- distance
- Computes the bitwise Hamming
distance between
xandy, that is, the number of bits wherexandydiffer, or, the number of set bits in the xor ofxandy. - distance_
fast - Computes the bitwise Hamming
distance between
xandy, that is, the number of bits wherexandydiffer, or, the number of set bits in the xor ofxandy. - weight
- Computes the Hamming
weight of
x, that is, the population count, or number of ones.