在线
客服

发布
需求

在线
聊天

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

连续两句相同的递归方法是如何执行的

private int getOptionVarArr_rec(VdsObj vdsObj, int r,                        List arrVarQuantset, List arrVarQuantRes,                        int[] applycache) {                if (r < 2) {                        return r;                }                List P_arrAllNodes = vdsObj.getP_arrAllNodes();                BddObj oNode = P_arrAllNodes.get(r);                int iLvl = oNode.getLevel();                 if (applycache[r] != -1)                        return applycache[r];                int res, val0, val1;                if (arrVarQuantset.get(iLvl) == 1)                        res = getOptionVarArr_rec(vdsObj, oNode.getHigh(), arrVarQuantset,                                        arrVarQuantRes, applycache);                else if (arrVarQuantset.get(iLvl) == 0)                         res = getOptionVarArr_rec(vdsObj, oNode.getLow(), arrVarQuantset,                                        arrVarQuantRes, applycache);                else {                         val0 = getOptionVarArr_rec(vdsObj, oNode.getLow(), arrVarQuantset,                                        arrVarQuantRes, applycache);                        val1 = getOptionVarArr_rec(vdsObj, oNode.getHigh(), arrVarQuantset,                                        arrVarQuantRes, applycache);                                                int iLowLvl = P_arrAllNodes.get(oNode.getLow()).getLevel();                                                int iHighLvl = P_arrAllNodes.get(oNode.getHigh()).getLevel();                         if (val0 == 1 && val1 == 1) {                                 arrVarQuantRes = setOneVarOption(iLvl, -2, arrVarQuantset,                                                arrVarQuantRes);                                                                if (iLvl + 1 < iLowLvl)                                        arrVarQuantRes = getOptionVarArr_rec_lvl(iLvl, iLowLvl,                                                        arrVarQuantset, arrVarQuantRes);                                if (iLvl + 1 < iHighLvl)                                        arrVarQuantRes = getOptionVarArr_rec_lvl(iLvl, iHighLvl,                                                        arrVarQuantset, arrVarQuantRes);                                res = 1;                        } else if (val0 == 1 && val1 == 0) {                                 arrVarQuantRes = setOneVarOption(iLvl, 0, arrVarQuantset,                                                arrVarQuantRes);                                if (iLvl + 1 < iLowLvl)                                        arrVarQuantRes = getOptionVarArr_rec_lvl(iLvl, iLowLvl,                                                        arrVarQuantset, arrVarQuantRes);                                res = 1;                        } else if (val0 == 0 && val1 == 1) {                                 arrVarQuantRes = setOneVarOption(iLvl, 1, arrVarQuantset,                                                arrVarQuantRes);                                if (iLvl + 1 < iHighLvl)                                        arrVarQuantRes = getOptionVarArr_rec_lvl(iLvl, iHighLvl,                                                        arrVarQuantset, arrVarQuantRes);                                res = 1;                        } else                                res = 0;                 }                        applycache[r] = res;                return res;        }不太明白val0 = getOptionVarArr_rec(vdsObj, oNode.getLow(), arrVarQuantset,
                                        arrVarQuantRes, applycache); 下的代码是如何执行。我的理解是不断的调用getOptionVarArr_rec方法,遇到r < 2为true时退出,但实际代码能执行下去val1的值

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

发新帖
国内首家创新型IT技术需求众包服务平台,软件需求就上天盟网! 立即登录 立即注册