1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/// Maps 32-bit `hash` to the range `[0, n)`, where `n` is a 32-bit integer.
///
/// Uses the algorithm described in: Daniel Lemire, *A fast alternative to the modulo reduction*,
/// <https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/>
/// Maps 16-bit `hash` to the range `[0, n)`, where `n` is a 16-bit integer.
///
/// Uses the algorithm described in: Daniel Lemire, *A fast alternative to the modulo reduction*,
/// <https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/>
/// Maps 64-bit `hash` to the range `[0, n)`, where `n` is a 32-bit integer.
///
/// Uses the algorithm described in: Daniel Lemire, *A fast alternative to the modulo reduction*,
/// <https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/>
/// Maps 64-bit `hash` to the range `[0, n)`, where `n` is a 64-bit integer.
///
/// Uses the algorithm described in: Daniel Lemire, *A fast alternative to the modulo reduction*,
/// <https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/>
// Maps 48-bit `hash` to the range `[0, n)`, where `n` is a 64-bit integer.
//
// Uses slightly modified version of the algorithm described in:
// Daniel Lemire, *A fast alternative to the modulo reduction*,
// <https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/>
/*#[inline(always)]
pub fn map48_to_64(hash: u64, n: u64) -> u64 {
((((hash << 16) as u128) * (n as u128)) >> 64) as u64
}*/ // the function is fine, but not needed
/// Maps `hash` to the range `[0, n)` using either [`map64_to_64`] or [`map32_to_32`] (depended on platform).