func passMap(m *omap.Map, t *testing.T) { for _, number := range []int{9, 3, 6, 4, 5, 0} { m.Insert(number, number) } if m.Len() != 7 { t.Errorf("should have %d items", 7) } }
func searchMap(omap *omap.Map, keys ...interface{}) { for _, key := range keys { if value, found := omap.Find(key); found { fmt.Printf("\"%v\" is in the omap with value %v\n", key, value) } else { fmt.Printf("\"%v\" isn't in the omap\n", key) } } }
func showMap(omap *omap.Map, data interface{}, name string, width int) { fmt.Println("original: ", data) fmt.Print("omap keys: [") gap := "" omap.Do(func(key, _ interface{}) { fmt.Print(gap, key) gap = " " }) fmt.Println("]") fmt.Print("omap values: [") gap = "" omap.Do(func(_, value interface{}) { fmt.Printf("%s%.*v", gap, width, value) gap = " " }) fmt.Println("]") fmt.Println(omap.Len(), name) }