//  hash value between 0 and M-1
func (st *SeparateChainingHashST) hash(key string) uint32 {
	h := dgohash.NewJava32()
	h.Write([]byte(key))
	bsum := h.Sum(nil)
	s := binary.BigEndian.Uint32(bsum)
	res := s & uint32(st.m-1)
	return res
}
Esempio n. 2
0
//  hash value between 0 and M-1
func (st *LinearProbingHashST) hash(key string) int {
	h := dgohash.NewJava32()
	h.Write([]byte(key))
	bsum := h.Sum(nil)
	s := binary.BigEndian.Uint32(bsum)
	res := int(s & uint32(st.m-1))
	//fmt.Println("key", key, "hash", res)
	return res
}