1.項目源碼(加載菜單樹)
private List<MenuInfoCopier> getMemus(MenuInfo menuInfo, List<MenuInfoCopier> totalMenuList) {
if (totalMenuList == null) {
totalMenuList = new ArrayList<>();
}
MenuInfoCopier currentMenuInfoCopier = getMenuInfoCopier(menuInfo);
totalMenuList.add(currentMenuInfoCopier);
if (menuInfo.getMenuList().size() > 0) {
for (MenuInfo childMenuInfo : menuInfo.getMenuList()) {
totalMenuList = getMemus(childMenuInfo, totalMenuList);
}
}
return totalMenuList;
}
2.遞歸的執行流程:
從上面可以看出,遞歸主要有兩個階段,遞推分解任務與任務的迴歸
(3).關於遞歸的運用模型與常見的面試題
參考博客:https://blog.csdn.net/qq_34039315/article/details/78679029
別人寫的太好,我都插不上嘴,只能大喊“666”!