Improve QuadNode.getChildValueCount()

This commit is contained in:
James Seibel
2023-04-08 10:21:03 -05:00
parent b013d93908
commit b11d1c4b3e
@@ -56,7 +56,10 @@ public class QuadNode<T>
/** @return the number of non-null child nodes */
/**
* Use {@link QuadNode#getChildValueCount()} if you want the number of non-null child values.
* @return the number of non-null child nodes
*/
public int getChildCount()
{
int count = 0;
@@ -70,14 +73,14 @@ public class QuadNode<T>
return count;
}
/** returns the number of children that have non-null values */
/** @return the number of children that have non-null values */
public int getChildValueCount()
{
int count = 0;
for (int i = 0; i < 4; i++)
{
QuadNode<T> child = this.getChildByIndex(i);
if (child != null && child.value != null)
if (child != null && (child.value != null || child.getChildValueCount() != 0))
{
count++;
}