我对如何使用整数键值调用MurmurHash3_x86_128()感到困惑,或者这是可能的吗?可以在https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp中找到murmurhash3代码。下面给出了方法定义。
void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t seed, void * out )我散列整数值,len为1。它是正确的还是错误的?
int main()
{
uint64_t seed = 100;
int p = 500; // key to hash
uint64_t hash_otpt[2]= {0};
const int *key = &p;
MurmurHash3_x64_128(key, 1, seed, hash_otpt); // 0xb6d99cf8
cout << *hash_otpt << endl;
}发布于 2016-11-20 18:18:35
您传递的是key,这是一个指向(const) int的指针,因此您应该传递sizeof(int)作为长度。
仅当int在您的平台上为1字节宽时,传递1才有效,这种情况很少发生。
https://stackoverflow.com/questions/40702815
复制相似问题