blob: 6749b0d8d3a21766d6594226c482f430a7788503 (
plain)
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
|
package search
type GoMap map[int]int
func NewGoMap() GoMap {
return make(GoMap)
}
func (m GoMap) Empty() bool {
return m.Size() == 0
}
func (m GoMap) Size() int {
return len(m)
}
func (m GoMap) Put(key, val int) {
m[key] = val
}
func (m GoMap) Get(key int) (int, error) {
val, ok := m[key]
if !ok {
return -1, NotFound
}
return val, nil
}
func (m GoMap) Del(key int) (int, error) {
val, ok := m[key]
if !ok {
return -1, NotFound
}
delete(m, key)
return val, nil
}
|