MCPcopy Create free account
hub / github.com/ua-nick/Data-Structures-and-Algorithms / Remove

Method Remove

HashTable/HashTable.go:53–71  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

51}
52
53func (table *HashTable) Remove(key string) bool {
54 position := generateHash(key)
55 if table.data[position] == nil {
56 return false
57 }
58 if table.data[position].key == key {
59 table.data[position] = table.data[position].next
60 return true
61 }
62 current := table.data[position]
63 for current.next != nil {
64 if current.next.key == key {
65 current.next = current.next.next
66 return true
67 }
68 current = current.next
69 }
70 return false
71}
72
73func generateHash(s string) uint8 {
74 hash := fnv.New32a()

Callers

nothing calls this directly

Calls 1

generateHashFunction · 0.85

Tested by

no test coverage detected