2022-04-08 11:36:53 +00:00
|
|
|
package treeiter_test
|
2022-02-19 23:23:36 +00:00
|
|
|
|
2022-04-08 11:36:53 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-10-02 19:32:41 +00:00
|
|
|
"gitlab.com/manytask/itmo-go/private/treeiter"
|
2022-04-08 11:36:53 +00:00
|
|
|
)
|
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",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-04-08 11:36:53 +00:00
|
|
|
treeiter.DoInOrder(tree, func(t *ValuesNode[string]) {
|
2022-02-19 23:23:36 +00:00
|
|
|
fmt.Println(t.value)
|
|
|
|
})
|
|
|
|
|
|
|
|
// Output:
|
|
|
|
// left
|
|
|
|
// root
|
|
|
|
// right
|
|
|
|
}
|