当前位置:网站首页>JS forest leaf node non recursive depth first postorder traversal
JS forest leaf node non recursive depth first postorder traversal
2022-06-25 20:09:00 【Fu Zongheng】
afterPreview(trees) {
let nodeList = [].concat(trees);
while (nodeList.length > 0) {
let currentNode = nodeList.pop();
if (currentNode.hasOwnProperty("children")) {
nodeList = nodeList.concat(currentNode.children);
}
else {
// Here is the leaf node
this.dataUpload(currentNode);
}
}
this.showUpdateFlag = true;
return trees;
}Please adjust it according to your own data structure .
remarks :
1. In the above methods
trees The structure is : [tree1,tree2,tree3]
tree The structure can be abstracted as :{
children:[leaf1,leaf2,leaf3]
}
leaf The structure is abstracted as :{
......
}
2. If you want a non leaf node , At the first if Handle under
边栏推荐
- DICOM to NII
- Jsonp processing non homologous
- Huawei fast application access advertising service development guide
- 2.2 step tariff
- Vulnhub range - correlation:2
- Vulnhub range the planes:earth
- <C>. String comparison
- Impact of Huawei application transfer and application claim on user identification
- Vulnhub range - the planes:venus
- Applet canvas generate sharing Poster
猜你喜欢

Wechat applet connects to the server to display mqtt data information

Transunet reading notes

Jsonp processing non homologous

Li-rads lesion classification reading notes

206. reverse linked list (insert, iteration and recursion)

LNMP compilation and installation
![[harmonyos] [arkui] how can Hongmeng ETS call pa](/img/19/9d2c68be48417e0aaa0d27068a67ce.jpg)
[harmonyos] [arkui] how can Hongmeng ETS call pa

Redis high availability: do you call this the principle of master-slave architecture data synchronization?

Wechat applet cloud function does not have dependency option installed

How to understand var = a = b = C = 9? How to pre parse?
随机推荐
2.14(Knight Moves)
Pcl+vs2019+opencv environment configuration
Wechat applet connects to the server to display mqtt data information
Verification code native JS canvas
打新债网上开户安全吗,需要注意什么
Remember to deploy selenium crawler on the server
NMS reduction box
<C>. array
Native JS array some method de duplication
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
Png to NII
String since I can perform performance tuning, I can call an expert directly
Yaml configuration
6. exception handling
JS asynchronism (III. usage of generator and async/await)
Pdf file download (the download name is the same as the file name)
Web container basic configuration
2021-08-25
2.1 write a program to calculate the sum and average of four integers.
How to understand var = a = b = C = 9? How to pre parse?