about summary refs log tree commit diff
path: root/structs.go
diff options
context:
space:
mode:
Diffstat (limited to 'structs.go')
-rw-r--r--structs.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/structs.go b/structs.go
index 5f916bd..76964fa 100644
--- a/structs.go
+++ b/structs.go
@@ -154,18 +154,22 @@ func (quadtree *Quadtree) Insert(point Coord) {
 	quadtree.pointsSlice = append(quadtree.pointsSlice, point)
 }
 
+// Print() is a method that can be used on a quadtree.
+// It prints all the root nodes of the quadtree recursively
+// The tree is printed from the bottom up in the following order: NW, NE, SW, SE
 func (quadtree *Quadtree) Print() {
-	if quadtree.northEast != nil {
-		quadtree.northEast.Print()
-	}
+	// Define an end condition: if the quadtree-leaf is nil, the root does not continue
 	if quadtree.northWest != nil {
 		quadtree.northWest.Print()
 	}
-	if quadtree.southEast != nil {
-		quadtree.southEast.Print()
+	if quadtree.northEast != nil {
+		quadtree.northEast.Print()
 	}
 	if quadtree.southWest != nil {
 		quadtree.southWest.Print()
 	}
+	if quadtree.southEast != nil {
+		quadtree.southEast.Print()
+	}
 	fmt.Println(quadtree)
 }