Beispiel #1
0
static int
_GATreeDepth(GANodeBASE * node)
{
  if(!node) return 0;
  int depth;
  int maxdepth = 1 + _GATreeDepth(node->child);
  for(GANodeBASE * tmp=node->next; tmp != node; tmp=tmp->next){
    depth = 1 + _GATreeDepth(tmp->child);
    maxdepth = maxdepth > depth ? maxdepth : depth;
  }
  return maxdepth;
}
Beispiel #2
0
// Return the number of levels in the tree.  We do a complete traversal of the
// tree and keep a count of the number of times we go down and come up a level.
// I should be able to combine _size and _depth so we don't have to do two
// traversals...
int
GATreeBASE::depth() const
{
  if(!cdpth) return dpth;
  GATreeBASE * This = (GATreeBASE *)this;
  This->cdpth = 0;
  return(This->dpth = _GATreeDepth(rt));
}
// Return the number of levels in the tree.  We do a complete traversal of the
// tree and keep a count of the number of times we go down and come up a level.
// I should be able to combine _size and _depth so we don't have to do two
// traversals...
int
GATreeBASE::depth() const
{
  if(!cdpth) return dpth;
  GATreeBASE * This = CON_CAST(GATreeBASE *, this);
  This->cdpth = 0;
  return(This->dpth = _GATreeDepth(rt));
}
Beispiel #4
0
/// Return the depth of the tree from the specified node on down.
int
GATreeIterBASE::depth(GANodeBASE * n)
{
    return(_GATreeDepth(n));
}