shad-go/treeiter/treeiter_example_test.go

29 lines
388 B
Go
Raw Permalink Normal View History

package treeiter_test
2022-02-19 23:23:36 +00:00
import (
"fmt"
"gitlab.com/slon/shad-go/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
}