// ToHashKey removes the leading and trailing zeros and generates a hash key.
// Two Decimals dec0 and dec1 with different fraction will generate the same hash keys if dec0.Compare(dec1) == 0.
334276
func (d *MyDecimal) ToHashKey() ([]byte, error) {
	_, digitsInt := d.removeLeadingZeros()
	_, digitsFrac := d.removeTrailingZeros()
	prec := digitsInt + digitsFrac
	if prec == 0 { // zeroDecimal
		prec = 1
	}
	buf, err := d.ToBin(prec, digitsFrac)
	if err == ErrTruncated {
		// This err is caused by shorter digitsFrac;
		// After removing the trailing zeros from a Decimal,
		// so digitsFrac may be less than the real digitsFrac of the Decimal,
		// thus ErrTruncated may be raised, we can ignore it here.
		err = nil
	}
	return buf, err
}
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)
}
649476
func HashKey(parts ...string) string {
	hash := sha256.New()
	bio := bufio.NewWriter(hash)

	// Add a full NULL-delimited key sequence segment to our hash.
	for i, part := range parts {
		// Write the separator, except for the first key.
		if i > 0 {
			if _, err := bio.WriteRune('\x00'); err != nil {
				panic(err)
			}
		}

		if _, err := bio.WriteString(part); err != nil {
			panic(err)
		}
	}
	if err := bio.Flush(); err != nil {
		panic(err)
	}

	// Return the hex-encoded hash sum.
	return hex.EncodeToString(hash.Sum(nil))
}
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)
}
335801
func keyToString(k []byte) string {
	if len(k) != lenHash {
		panic(fmt.Sprintf("bad hash passed to hashToKey: %x", k))
	}
	return fmt.Sprintf("%s%x", hashPrefix, k)[0:lenKey]
}
841579
func (h *HashMap) DelKey(elementid, key string) error {
	if h.name == nil {
		return ErrDoesNotExist
	}
	return (*bbolt.DB)(h.db).Update(func(tx *bbolt.Tx) error {
		bucket := tx.Bucket(h.name)
		if bucket == nil {
			return ErrBucketNotFound
		}
		return bucket.Delete([]byte(elementid + ":" + key))
	})
}
694167
func (hm *HashMap) Keys() (ch chan Hashable) {
	ch = make(chan Hashable)
	go func() {
		defer close(ch)
		for _, v := range hm.keys {
			ch <- v
		}
	}()
	return
}
46046
func (m *MockHasher) Hash(arg0 context.Context, arg1 []byte) ([]byte, error) {
	ret := m.ctrl.Call(m, "Hash", arg0, arg1)
	ret0, _ := ret[0].([]byte)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
30014
func HashUInt32(input uint32) uint32 {
	if input == 0 {
		return 0
	}

	key := MixKey(input)
	hash := MixHash(seed, key)
	return Finalize(hash, 4)
}
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)
}
567806
func (h Hash) Bytes(key string) []byte {
	if value, ok := h[key]; ok {
		return value.Bytes()
	}
	return []byte{}
}
1089597
func (hm *SyncedHashMap) Keys() (ch chan Hashable) {
	ch = make(chan Hashable)
	go func() {
		hm.RLock()
		defer hm.RUnlock()
		defer close(ch)
		for _, v := range hm.keys {
			ch <- v
		}
	}()
	return
}
482834
func BytesToHash(b []byte) Hash {
	var h Hash
	h.SetBytes(b)
	return h
}
189654
func headerTDKey(number uint64, hash common.Hash) []byte {
	return append(headerKey(number, hash), headerTDSuffix...)
}
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)
}
1154603
func (a Tags) AppendHashKey(dst []byte) []byte {
	// Empty maps marshal to empty bytes.
	if len(a) == 0 {
		return dst
	}

	// Type invariant: Tags are sorted

	sz := 0
	var escaped Tags
	if a.needsEscape() {
		var tmp [20]Tag
		if len(a) < len(tmp) {
			escaped = tmp[:len(a)]
		} else {
			escaped = make(Tags, len(a))
		}

		for i := range a {
			t := &a[i]
			nt := &escaped[i]
			nt.Key = escapeTag(t.Key)
			nt.Value = escapeTag(t.Value)
			sz += len(nt.Key) + len(nt.Value)
		}
	} else {
		sz = a.Size()
		escaped = a
	}

	sz += len(escaped) + (len(escaped) * 2) // separators

	// Generate marshaled bytes.
	if cap(dst)-len(dst) < sz {
		nd := make([]byte, len(dst), len(dst)+sz)
		copy(nd, dst)
		dst = nd
	}
	buf := dst[len(dst) : len(dst)+sz]
	idx := 0
	for i := range escaped {
		k := &escaped[i]
		if len(k.Value) == 0 {
			continue
		}
		buf[idx] = ','
		idx++
		copy(buf[idx:], k.Key)
		idx += len(k.Key)
		buf[idx] = '='
		idx++
		copy(buf[idx:], k.Value)
		idx += len(k.Value)
	}
	return dst[:len(dst)+idx]
}
46036
func hash(key uint64) uint64 {
	key ^= key >> 33
	key *= 0xff51afd7ed558ccd
	key ^= key >> 33
	key *= 0xc4ceb9fe1a85ec53
	key ^= key >> 33
	return key
}