为什么我的方法进入无限递归? [英] Why is my method going into infinite recursion?
问题描述
我写了一个方法来帮助构建一个四叉树。每个四叉树都有一个根节点,一个根节点有4个子节点。我使用深度递归来阻止这个函数划分太多次。传入的深度等于正方形边的对数底2(一个正方形总是传入)。但是,我从这里得到无限递归。任何人都看到为什么?
I've written a method to help build a quadtree. Each quadtree has a root node, and a root node has 4 children. I'm using depth recursion to stop this function from dividing too many times. The depth that is passed in is equal to the log base 2 of the side of the square (a square is always passed in). However, I get infinite recursion from this. Anyone see why?
当我运行它时,输出是Depth = 0无限多次..
When I run it, the output is "Depth=0" infinitely many times..
推荐答案
如果 n-> isLeaf()
条件表示all n
's children are null,那么我想这里总是false。
If the n->isLeaf()
condition means "all n
's children are null", then I suppose it is always false here.
这篇关于为什么我的方法进入无限递归?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!