RemoveChildrenWithPrefix
Removes the node with the specified prefix.
int RemoveChildrenWithPrefix( LPCSTR lpcszPrefix = NULL )
the number of nodes mathced and was removed successfully; 0 otherwise.
EX1
// Remove the children with prefix n void TreeNode_RemoveChildrenWithPrefix_ex1() { Tree myTree; TreeNode tn1, tn2; tn1 = myTree.AddNumericNode(5, "Name", 1); tn2 = myTree.AddNumericNode(6, "Addr", 1); printf("number of nodes = %d \n", myTree.GetNodeCount()); //should print 2 int flag = myTree.RemoveChildrenWithPrefix("n"); printf("number of nodes = %d \n", myTree.GetNodeCount()); //should print 1 }
EX2
// Use "" to remove all the children void TreeNode_RemoveChildrenWithPrefix_ex2() { Tree myTree; TreeNode tn1, tn2; tn1 = myTree.AddNumericNode(5, "Name", 1); tn2 = myTree.AddNumericNode(6, "Addr", 1); printf("number of nodes = %d \n", myTree.GetNodeCount()); //should print 2 int flag = myTree.RemoveChildrenWithPrefix(""); printf("number of nodes = %d \n", myTree.GetNodeCount()); //should print 0 }
TreeNode::RemoveChild
origin.h