当前位置:网站首页>树形结构构造示例代码
树形结构构造示例代码
2022-08-02 20:36:00 【jsxztshaohaibo】
/** * 构造树形结构 * @param resourceList * @return */ public List<RResource> buildResourceTreeInfo(List<RResource> resourceList) { List<RResource> result = new ArrayList<>(); Map<String,RResource> record = new HashMap<>(); for (RResource resource : resourceList) { if (RResource.TOP_LEVEL_NODE.equals(resource.getParentId())) {//TOP_LEVEL_NODE=0 resource.setChildren(new ArrayList<>()); result.add(resource); } record.put(resource.getId(), resource); } for (RResource resource : resourceList) { if (StringUtils.isNotBlank(resource.getParentId()) &&!RResource.TOP_LEVEL_NODE.equals(resource.getParentId())) {//TOP_LEVEL_NODE=0 RResource parent = record.get(resource.getParentId()); if (parent != null) { parent.getChildren().add(resource); } } } return result; }
边栏推荐
- [C题目]力扣234. 回文链表
- go——垃圾回收机制(GC)
- Informatics orsay a tong (1258: 【 9.2 】 digital pyramid)
- Wiring diagrams of switches, motors, circuit breakers, thermocouples, and meters
- DataGrip 安装教程 详细版
- 回文自动机+CodeTON Round 2 C,D
- 框架设计:PC 端单页多页框架如何设计与落地
- vscode如何能将输出从OUTPUT改为TERMINAL或者DebugConsole
- ICLR 2022最佳论文:基于对比消歧的偏标签学习
- VisualStudio 制作Dynamic Link Library动态链接库文件
猜你喜欢
Qt提升自定义控件,找不到头文件
.NET performance optimization - you should set initial size for collection types
DataGrip 安装教程 详细版
SublimeText3 安装、配置项、包管理、常用必备插件、常用快捷键以及修改
sre成长之路
华为设备配置BFD多跳检测
【SLAM】DM-VIO(ros版)安装和论文解读
Informatics Olympiad All-in-One (1259: [Example 9.3] Find the longest non-descending sequence)
软件成分分析:华为云重磅发布开源软件治理服务
Tencent YunMeng every jie: I experienced by cloud native authors efficiency best practices case
随机推荐
Day12 接口和协议
【目标检测】YOLOv5:640与1280分辨率效果对比
How the sensor works
14、学习MySQL 连接的使用
Linphone 被叫方如何解析来电SIP消息中的自定义头消息
【SLAM】DM-VIO(ros版)安装和论文解读
PLC working principle animation
js如何获取浏览器缩放比例
[C题目]力扣1. 两数之和
The Orsay in Informatics (1256: Bouquet for Algernon)
ICLR 2022最佳论文:基于对比消歧的偏标签学习
用户之声 | 大学生的“课外学堂”
postgresql autovaccum自动清理
.NET如何快速比较两个byte数组是否相等
Use the TCP protocol, we won't lost package?
js how to get the browser zoom ratio
Day35 LeetCode
【21天学习挑战赛】冒泡排序与插入排序
奥特学园ROS笔记--7(289-325节)
数据库分析与优化