Skip to content

Instantly share code, notes, and snippets.

@onemouth
Last active July 17, 2019 10:47
Show Gist options
  • Save onemouth/0631b2ff53e1ae2a98571fe50ea30ac0 to your computer and use it in GitHub Desktop.
Save onemouth/0631b2ff53e1ae2a98571fe50ea30ac0 to your computer and use it in GitHub Desktop.
func (m *Map) Get(key string) string {
hash := int(m.hash([]byte(key)))
idx := sort.Search(len(m.keys),
func(i int) bool { return m.keys[i] >= hash }
)
if idx == len(m.keys) {
idx = 0
}
return m.hashMap[m.keys[idx]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment