int BSTree<T>::BSTreeDepth(BSTree<T> *&BST) {if(BST==NULL) return 0;//对于空树,返回0并结束递归 else { //计算左子树的深度 int dep1=BSTreeDepth(BST->left); //计算右子树的深度 int dep2=BSTreeDepth(BST->right); //返回树的深度 if(dep1>dep2) return dep1+1; else return dep2+1;} }
static bool pnamesUsePath (const char * path) { bool ret; STSMSG (4, ("Use path called %s", path)); STSMSG (4, ("Depth %u ", BSTreeDepth(&pnames, false) )); if (BSTreeDepth(&pnames, false) == 0) { /* PLOGMSG (klogDebug9, "pnamesUsePath use $(P) by default", PLOG_S(P), path); */ ret = true; } else { ret = ( BSTreeFind (&pnames, path, pnameFindCmp ) != NULL); /* if (ret) */ /* PLOGMSG (klogDebug9, "pnamesUsePath use $(P)", PLOG_S(P), path); */ /* else */ /* PLOGMSG (klogDebug9, "pnamesUsePath don't use $(P)", PLOG_S(P), path); */ } STSMSG (4, ("Use? %u ", ret)); return ret; }