Skip to content

Commit

Permalink
add note
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 4, 2024
1 parent 90966f0 commit 45cdf96
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/fdr-sdk/src/utils/traversers/prunetree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface PruneTreeOptions<NODE, PARENT extends NODE = NODE, POINTER = NODE> {
getPointer?: (node: NODE) => POINTER;
}

// TODO: this algorithm is not optimal, as it traverses the tree twice, and should be refactored to traverse only once
// it would be more efficient to BFS the tree once, collect all the nodes in an array, and reverse the array to delete the nodes from the bottom up
export function prunetree<NODE, ROOT extends NODE = NODE, PARENT extends NODE = NODE, POINTER = NODE>(
root: ROOT,
opts: PruneTreeOptions<NODE, PARENT, POINTER>,
Expand Down

0 comments on commit 45cdf96

Please sign in to comment.