コード例 #1
0
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)
		}
	}
}
コード例 #2
0
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)
}