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”!