shad-go/treeiter/treeiter_example_test.go

29 lines
399 B
Go
Raw Normal View History

package treeiter_test
2022-02-19 23:23:36 +00:00
import (
"fmt"
2023-10-03 17:25:41 +00:00
"gitlab.com/manytask/itmo-go/public/treeiter"
)
2022-02-19 23:23:36 +00:00
func ExampleDoInOrder() {
tree := &ValuesNode[string]{
value: "root",
left: &ValuesNode[string]{
value: "left",
},
right: &ValuesNode[string]{
value: "right",
},
}
treeiter.DoInOrder(tree, func(t *ValuesNode[string]) {
2022-02-19 23:23:36 +00:00
fmt.Println(t.value)
})
// Output:
// left
// root
// right
}