MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / hash

Method hash

structure/hashmap/hashmap.go:107–112  ·  view source on GitHub ↗

hash generates a hash value for the given key

(key any)

Source from the content-addressed store, hash-verified

105
106// hash generates a hash value for the given key
107func (hm *HashMap) hash(key any) uint64 {
108 h := fnv.New64a()
109 _, _ = h.Write([]byte(fmt.Sprintf("%v", key)))
110 hashValue := h.Sum64()
111 return (hm.capacity - 1) & (hashValue ^ (hashValue >> 16))
112}

Callers 2

PutMethod · 0.95
getNodeByKeyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected