| 141 | static unsigned long rk_hash(unsigned long key); |
| 142 | |
| 143 | void rk_seed(unsigned long seed, rk_state *state) { |
| 144 | int pos; |
| 145 | seed &= 0xffffffffUL; |
| 146 | |
| 147 | /* Knuth's PRNG as used in the Mersenne Twister reference implementation */ |
| 148 | for (pos = 0; pos < RK_STATE_LEN; pos++) { |
| 149 | state->key[pos] = seed; |
| 150 | seed = (1812433253UL * (seed ^ (seed >> 30)) + pos + 1) & 0xffffffffUL; |
| 151 | } |
| 152 | state->pos = RK_STATE_LEN; |
| 153 | state->gauss = 0; |
| 154 | state->has_gauss = 0; |
| 155 | state->has_binomial = 0; |
| 156 | } |
| 157 | |
| 158 | /* Thomas Wang 32 bits integer hash function */ |
| 159 | unsigned long rk_hash(unsigned long key) { |
no outgoing calls