コード例 #1
0
 public void VerifySphereTree()
 {
     if (leafNode)
     {
         Debug.Assert(CountChildren() == 0, "leaf child count non-zero");
         Debug.Assert(containedShape != null, "leaf shape null");
         Debug.Assert(Contains(containedShape), "leaf doesn't contain shape");
     }
     else
     {
         int count = CountChildren();
         if (parent != null) // Don't make the test for the root node
         {
             Debug.Assert(count > 0, "non-leaf with no children");
         }
         for (int i = 0; i < childCount; i++)
         {
             SphereTreeNode child = children[i];
             if (child != null)
             {
                 Debug.Assert(Contains(child), "non-leaf doesn't contain child");
                 Debug.Assert(child.parent == this, "child doesn't point to parent");
                 if (!child.leafNode && count == 1)
                 {
                     Debug.Assert(child.CountChildren() > 1, "this node has only one child, which has only one child");
                 }
                 child.VerifySphereTree();
             }
         }
     }
 }