Sujet : Re: Good hash for pointers
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.cDate : 26. May 2024, 18:54:17
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v2vt07$3gk4l$1@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
Am 26.05.2024 um 19:39 schrieb Bonita Montero:
Am 26.05.2024 um 19:20 schrieb Tim Rentsch:
I say the output quality is poor because I have run tests that
show the poor output quality.
If you chose a prime whose double is beyond 64 bit there's an
equal distribution among the 64 bit modulos.
I've done that with a prime of my own choosing and also with
18446744073709551557, the value you suggested.
Show me your code.
This is the bucket's loads of my hash-algorithm with a number which
is a multiple of eight, i.e. uint64_t-aligned data:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<size_t> buckets( (1ull << 30) / sizeof(size_t) );
for( size_t b = buckets.size(); b; )
++buckets[(size_t)(--b * 8u * 0xFFFFFFFFFFFFFFc5u) % buckets.size()];
vector<size_t> loads;
for( size_t f : buckets )
{
if( loads.size() <= f )
loads.resize( f + 1 );
++loads[f];
}
for( size_t l = 0; size_t ld : loads )
cout << ++l << ": " << ld << endl;
}
1: 117440512
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 16777216