deno.land / x / masx200_leetcode_test@10.6.5 / NyZD2B / traverseInOrder.ts

traverseInOrder.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { BinarySearchTree } from "https://esm.sh/@datastructures-js/binary-search-tree@5.0.2/?dts";
export function traverseInOrder< T extends BinarySearchTree<any>,>( tree: T, cb: (node: NonNullable<ReturnType<T["root"]>>) => void, signal?: AbortSignal,) { if (typeof cb !== "function") { throw new Error(".traverseInOrder expects a callback function"); }
const traverseRecursive = (current: ReturnType<T["root"]> | null) => { if (signal?.aborted) { return; } if (current === null) { return; } //@ts-ignore traverseRecursive(current.getLeft()); if (signal?.aborted) { return; } //@ts-ignore cb(current); //@ts-ignore traverseRecursive(current.getRight()); }; //@ts-ignore traverseRecursive(tree.root());}
masx200_leetcode_test

Version Info

Tagged at
a year ago