// Hash consistently chooses a hash bucket number in the range [0, numBuckets) for the given key. numBuckets must be >= 1.
487121
func Hash(key uint64, numBuckets int) int32 {

	var b int64 = -1
	var j int64

	for j < int64(numBuckets) {
		b = j
		key = key*2862933555777941757 + 1
		j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1)))
	}

	return int32(b)
}
929075
func hash(body string) string {
	buf := sha256.New()
	fmt.Fprintf(buf, "blob %d", len(body))
	buf.Write([]byte{0})
	buf.Write([]byte(body))
	return "v2:" + hex.EncodeToString(buf.Sum(nil))
}
455124
func (str String) Hash() int {
	h := xxhash.ChecksumString64S(string(str), hashSeed0)
	return int(h)
}
858115
func (bm *bucketMeta) setHash(hashKey string, hashVal []byte) {
	bm.hashesLock.Lock()
	bm.hashes[hashKey] = hashVal
	bm.hashesLock.Unlock()
}
1287467
func (data *Data) Hash() cmn.HexBytes {
	if data == nil {
		return (Txs{}).Hash()
	}
	if data.hash == nil {
		data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
	}
	return data.hash
}
516883
func (c Cmd) hash() cmdHash {
	output := c.Name
	for _, arg := range c.Args {
		output += fmt.Sprintf("%v", arg)
	}
	return cmdHash(output)
}
247715
func (body *Body) Hash() (h string) {
	b := body.Buffer()
	// empty buffs should return a empty string
	if b.Len() == 0 {
		h = HashStr("")
	}
	h = HashStr(b.String())
	return
}
1139851
func (t *NetworkDevice) Hash() uint64 {
	h := fnv.New64a()
	fmt.Fprintf(h, "%s\n%s\n%s\n%s",
		t.Metro,
		t.Role,
		t.Hostname,
		t.Hostgroup)
	return h.Sum64()
}
494488
func (h Hash) Int(key string) (int, error) {
	if value, ok := h[key]; ok {
		return value.Int()
	}
	return 0, errors.New(ErrInvalidKey, errorMessages, key)
}
674213
func (ac *ArrayComprehension) Hash() int {
	return ac.Term.Hash() + ac.Body.Hash()
}
705492
func (h *HashMap) Hash() int {
	var hash int
	h.Iter(func(k, v T) bool {
		hash += h.hash(k) + h.hash(v)
		return false
	})
	return hash
}
625658
func (bf *Filter) hash(hashNum uint32, data []byte) uint32 {
	// bitcoind: 0xfba4c795 chosen as it guarantees a reasonable bit
	// difference between hashNum values.
	//
	// Note that << 3 is equivalent to multiplying by 8, but is faster.
	// Thus the returned hash is brought into range of the number of bits
	// the filter has and returned.
	mm := MurmurHash3(hashNum*0xfba4c795+bf.msgFilterLoad.Tweak, data)
	return mm % (uint32(len(bf.msgFilterLoad.Filter)) << 3)
}
679533
func hashBytesToBucket(bucketCount int, res uint64) int {
	mod := res % uint64(bucketCount)
	return int(mod)
}
1343167
func (h *jmphasher) Hash(key uint64, n int) int {
	b, j := int64(-1), int64(0)
	for j < int64(n) {
		b = j
		key = key*uint64(2862933555777941757) + 1
		j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1)))
	}
	return int(b)
}
636212
func hash(rrs []dns.RR) uint32 {
	h := fnv.New32()
	buf := make([]byte, 256)
	for _, r := range rrs {
		off, err := dns.PackRR(r, buf, 0, nil, false)
		if err == nil {
			h.Write(buf[:off])
		}
	}

	i := h.Sum32()
	return i
}
1039770
func (h *Hasher) Hash(key string) int {
	return int(HashString(key, h.n, h.h))
}
586171
func (num Number) Hash() int {
	f, err := json.Number(num).Float64()
	if err != nil {
		bs := []byte(num)
		h := xxhash.Checksum64(bs)
		return int(h)
	}
	return int(f)
}