Skip to content

Commit 8e5c0b0

Browse files
author
farhansolodev
committed
can now print nodes for debugging
1 parent 4f0091c commit 8e5c0b0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

qnode.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package main
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
"strings"
6+
)
47

58
type QNode struct {
69
northwest *QNode
@@ -113,6 +116,10 @@ func (node *QNode) getMidValues() (x, y float32) {
113116
}
114117

115118
func (node *QNode) String() string {
116-
midX, midY := node.getMidValues()
117-
return fmt.Sprintf("[Node: (%f, %f)]", midY, midX)
119+
var sb strings.Builder
120+
node.forEach(func (node *QNode) {
121+
midX, midY := node.getMidValues()
122+
sb.WriteString(fmt.Sprintf("%s[Node: (%f, %f)]\n", strings.Repeat("-> ", int(node.depth)), midX, midY))
123+
}, 10)
124+
return sb.String()
118125
}

0 commit comments

Comments
 (0)