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

Method Add

HashTable/HashTable.go:15–26  ·  view source on GitHub ↗
(key string, i int)

Source from the content-addressed store, hash-verified

13}
14
15func (table *HashTable) Add(key string, i int) {
16 position := generateHash(key)
17 if table.data[position] == nil {
18 table.data[position] = &TableItem{key: key, data: i}
19 return
20 }
21 current := table.data[position]
22 for current.next != nil {
23 current = current.next
24 }
25 current.next = &TableItem{key: key, data: i}
26}
27
28func (table *HashTable) Get(key string) (int, bool) {
29 position := generateHash(key)

Callers

nothing calls this directly

Calls 1

generateHashFunction · 0.85

Tested by

no test coverage detected