示例#1
0
文件: examples_test.go 项目: bsm/bst
func ExampleMapIterator() {
	set := bst.NewMap(5)
	set.Set(bst.Int(5), "bar")
	set.Set(bst.Int(3), "foo")

	for iter := set.Iterator(); iter.Next(); {
		fmt.Println(iter.Key(), iter.Value())
	}
	// Output:
	// 3 foo
	// 5 bar
}
示例#2
0
文件: examples_test.go 项目: bsm/bst
func ExampleMap() {
	set := bst.NewMap(5)
	set.Set(bst.Int(5), "bar")
	set.Set(bst.Int(3), "foo")

	value, ok := set.Get(bst.Int(3))
	fmt.Println(value, ok)
	value, ok = set.Get(bst.Int(4))
	fmt.Println(value, ok)
	// Output:
	// foo true
	// <nil> false
}