java 线型集合转树形集合 o(n)
public static List<Zone> buildTree3(List<Zone> zoneList) {
Map<String, List<Zone>> zoneByParentIdMap = zoneList.stream().collect(Collectors.groupingBy(Zone::getParentId));
zoneList.forEach(zone->zone.children = zoneByParentIdMap.get(zone.id));
return zoneList.stream().filter(v -> v.parentId.equals("0")).collect(Collectors.toList());
}