0

我对我应该如何用整数键值调用 MurmurHash3_x86_128() 感到困惑,或者它甚至可能吗?murmurhash3 代码可以在https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp找到。方法定义如下。

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;

}
4

1 回答 1

1

您正在传递key,它是指向 (const) 的指针int,因此您应该sizeof(int)作为长度传递。

传递 1 仅int在您的平台上为 1 字节宽的情况下才有效,这种情况很少见。

于 2016-11-20T10:18:34.803 回答