package main
import "fmt"
type HashMap struct {
items map[string]int
}
func (h *HashMap) Init() {
h.items = make(map[string]int)
}
func (h *HashMap) Insert(key string, value int) {
h.items[key] = value
}
func (h *HashMap) Get(key string) int {
if value, found := h.items[key]; found {
return value
}
return -1
}
func (h *HashMap) Delete(key string) {
delete(h.items, key)
}
func main() {
hashMap := HashMap{}
hashMap.Init()
hashMap.Insert("a", 1)
hashMap.Insert("b", 2)
fmt.Println(hashMap.Get("a"))
fmt.Println(hashMap.Get("b"))
hashMap.Delete("a")
fmt.Println(hashMap.Get("a"))
}