Example #1
0
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
}
Example #2
0
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
}