Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // getChildren(win) - returns array of windows that are child to `win`
- // isTrue(win) - just a random callback
- function recurseDFS(win) {
- // depth first
- let coll = [];
- coll.push(isTrue(win));
- let children = getChildren(win);
- for (let child of children) {
- coll.push(...recurseDFS(child));
- }
- return coll;
- }
- function recurseBFS(win) {
- // breadth first
- let coll = [];
- let todo = [win];
- while (todo.length) {
- let cur = todo.shift();
- coll.push(isTrue(cur));
- todo.push(...getChildren(cur));
- }
- return coll;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement