updateTreeWithSearchingTitle<T extends AbsNodeType> function
Update field isShowedInSearching
of every node based on searching text.
Implementation
void updateTreeWithSearchingTitle<T extends AbsNodeType>(
TreeType<T> tree, String searchingText) {
var root = findRoot(tree);
// searching text is empty -> mark all nodes displayable
if (searchingText.isEmpty) {
_updateFullTrueIsShowedInSearching<T>(root);
return;
}
//? Step 1: Mark entire tree to non-displayable
_updateFullFalseIsShowedInSearching<T>(root);
//? Step 2: Find all nodes that contains searching text
List<TreeType<T>> foundNodes = [];
searchAllTreesWithTitleDFS<T>(root, searchingText, foundNodes);
//? Step 3: Update all branches from founded nodes to root as displayable
for (var node in foundNodes) {
_updateAncestorsToDisplayable<T>(node);
}
}