-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.go
More file actions
46 lines (34 loc) · 958 Bytes
/
Copy pathsearch.go
File metadata and controls
46 lines (34 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package SmallData
func search(hashTable *HashTable, k int) *HashTableData {
index := hashCode(k)
for _, _ = range hashTable.Table {
if hashTable.Table[index].Key == k {
return &hashTable.Table[index]
}
index++
index %= maxTableSize
}
return nil
}
// Search searchs for the HashTableData entry of the value of the given int key
func (ht *HashTable) SearchForData(k int) *HashTableData {
return search(ht, k)
}
// SearchString searchs for the string Value of the given string Key
func (ht *HashTable) SearchString(k string) string {
dat := ht.SearchForData(hashString(k))
if dat == nil {
warningf("value for key: %s not found", k)
return ""
}
return string(dat.Value)
}
// SearchString searchs for the string Value of the given string Hashed Key Int
func (ht *HashTable) SearchKey(k int) string {
dat := search(ht, k)
if dat == nil {
warningf("value for key: %d not found", k)
return ""
}
return string(dat.Value)
}