github.com/moontrade/nogc@v0.1.7/hash/murmur.go (about)

     1  package hash
     2  
     3  import "math/bits"
     4  
     5  func Murmur32(v uint32) uint32 {
     6  	const (
     7  		c1   uint32 = 0xcc9e2d51
     8  		c2   uint32 = 0x1b873593
     9  		seed uint32 = 0x1f576b93
    10  	)
    11  	h1 := seed
    12  	k1 := v
    13  
    14  	k1 *= c1
    15  	k1 = bits.RotateLeft32(k1, 15)
    16  	k1 *= c2
    17  
    18  	h1 ^= k1
    19  	h1 = bits.RotateLeft32(h1, 13)
    20  	h1 = h1*5 + 0xe6546b64
    21  
    22  	h1 ^= 4
    23  
    24  	h1 ^= h1 >> 16
    25  	h1 *= 0x85ebca6b
    26  	h1 ^= h1 >> 13
    27  	h1 *= 0xc2b2ae35
    28  	h1 ^= h1 >> 16
    29  
    30  	return h1
    31  }