pub fn f2(byte: u8, q: u8, n: u8) -> u8Expand description
Calculates the function f2 for the PHF. For the exact formula, please read the code.
When q == 0, the operation is a simple modulus.
The argument n is used only for taking the modulus so that the return value is
in the range [0, n).
ยงExamples
use zerotrie::_internal::f2;
const N: u8 = 10;
// With q = 0:
assert_eq!(0, f2(0, 0, N));
assert_eq!(1, f2(1, 0, N));
assert_eq!(2, f2(2, 0, N));
assert_eq!(9, f2(9, 0, N));
assert_eq!(0, f2(10, 0, N));
assert_eq!(1, f2(11, 0, N));
assert_eq!(2, f2(12, 0, N));
assert_eq!(9, f2(19, 0, N));
// With q = 1:
assert_eq!(1, f2(0, 1, N));
assert_eq!(0, f2(1, 1, N));
assert_eq!(3, f2(2, 1, N));
assert_eq!(8, f2(9, 1, N));
assert_eq!(1, f2(10, 1, N));
assert_eq!(0, f2(11, 1, N));
assert_eq!(3, f2(12, 1, N));
assert_eq!(8, f2(19, 1, N));