Unique int to int hash

后端 未结 5 1548
悲哀的现实
悲哀的现实 2020-12-11 08:41

I\'m curious as to whether or not there\'s some simple and/or well known hash method with the following properties:

  1. It transforms a 32-bit int into another 32-
5条回答
  •  旧时难觅i
    2020-12-11 09:08

    A simple approach: hash(x) = rotate-shl(x, K1) xor C

    You can combine several simple operations to achieve more "random" result, like rotate-shl/shr, bit-reverse, xor, not and so on.

提交回复
热议问题