bfsByLoop
广度优先遍历-循环的方式
配置项
| 参数 | 类型 | 是否必选 | 默认值 | 参数描述 |
|---|---|---|---|---|
| nodes | Array | 是 | - | 源数组 |
| callback | Function | 是 | - | 回调函数,接收当前节点数据 |
返回值
| 类型 | 描述 |
|---|---|
| void | - |
示例
// 待补充源码
js
export function bfsByLoop(nodes, callback) {
let node, curTree = nodes;
while ((node = curTree.shift())) {
callback(node);
if (node.children) {
curTree.push(...node.children);
}
}
}
@keyboarder-yang