Walk all tree nodes and get the tree node with given data id
TreeNode tree_get_node_by_dataid( TreeNode & tr, int nDataID, bool bRecursive = false, int nSearchLevel = 0 )
the TreeNode with given data id if successful. An invalid TreeNode if not sucessful.
Note: If nSearchLevel > 0, recursion to nSearchLevel levels occurs even if is bRecursive false.
See Also: tree_find_node_by_dataID for faster search using parent node data id's and repeat id's.
EX1
void tree_get_node_by_dataid_ex1() { Tree myTree; TreeNode trPh = myTree.AddNode("physics"); trPh.ExamMonth.strVal = "May"; TreeNode trMath = myTree.AddNode("Math"); TreeNode trTeacher = trMath.AddTextNode("Danice", "Teather"); trTeacher.DataID = 1; trTeacher.Other1.strVal = "Male"; trTeacher.Other1.DataID = 3; TreeNode trCount = trMath.AddNumericNode(100, "Count"); trCount.DataID = 2; trCount.Other2.strVal = "First"; trCount.Other2.DataID = 4; TreeNode trFirst = trMath.AddNumericNode(55, "Hello"); trFirst.DataID = 5; TreeNode tn = tree_get_node_by_dataid(myTree, 4, false, 2); if( tn ) { out_str("Yes!"); out_tree(tn); } else out_str("No!"); }
tree_find_node_by_dataID
origin.h