, , . 4 , 4 2 mallocs. . :
20125e8
20125e6
20125e7
20125e4
3fef2131
3fef2130
3fef212f
3fef212c
25e4802
25e4806
:
- LSB ( ) 'on' 'off'. . 2 LSB .
- , 8-10 . .
- , 64- 48 .
:
a >>= 2;
a &= 0x3fffffffffff;
msbs = (a >> 32) << 18;
a ^= msbs;
" " -, , . " " , :
uint32_t half_avalanche( uint32_t a)
{
a = (a+0x479ab41d) + (a<<8);
a = (a^0xe4aa10ce) ^ (a>>5);
a = (a+0x9942f0a6) - (a<<14);
a = (a^0x5aedd67d) ^ (a>>3);
a = (a+0x17bea992) + (a<<7);
return a;
}
10- 10 MSB uint32_t. - , N MSB - N, .
I was a little bored, so I wrote a toy test for this. Nothing out of the ordinary, it allocates a bunch of memory on the heap and tries to use the hash described above. The source may be here . Result:
1024 buckets, 256 values, 29 collisions
1024 buckets, 512 values, 103 collisions
1024 codes, 1024 values, 370 collisions
Next: I tried the other two hashes that are given here. Both of them have the same performance. Looks like: just choose the fastest;)
source
share