2.2.3.17.31 TreeNode::RemoveChildRemoveChild
Description
Removes the node with the specified id.
Removes the node with the specified name.
Removes the node specified by the object.
Syntax
BOOL RemoveChild( int nChildID )
BOOL RemoveChild( LPCSTR Name )
BOOL RemoveChild( TreeNode & tn )
Parameters
- nChildID
- [input] id of the node to be removed
- Name
- [input]name of the node to be removed
- tn
- [modify] the node object that has to be removed
Return
TRUE if the node existed and was removed successfully; FALSE otherwise.
TRUE if the node existed and was removed successfully; FALSE otherwise.
TRUE if the node existed and was removed successfully; FALSE otherwise.
Examples
EX1
// Remove child with the specified ID.
void TreeNode_RemoveChild_ex1()
{
Tree myTree;
TreeNode tn1;
tn1 = myTree.AddNumericNode(5, "node1", 1);
printf("number of nodes = %d\n", myTree.GetNodeCount());
bool flag = myTree.RemoveChild(1); //Child ID is 1
printf("number of nodes = %d\n", myTree.GetNodeCount());
}
EX2
// Remove child with the specified name.
void TreeNode_RemoveChild_ex2()
{
Tree myTree;
TreeNode tn1;
tn1 = myTree.AddNumericNode(5, "node1", 1);
printf("number of nodes = %d\n", myTree.GetNodeCount());
bool flag = myTree.RemoveChild("node1"); //Child name is "node1"
printf("number of nodes = %d\n", myTree.GetNodeCount());
}
EX3
// Remove child by the node name.
void TreeNode_RemoveChild_ex3()
{
Tree myTree;
TreeNode tn1;
tn1 = myTree.AddNumericNode(5, "node1", 1);
printf("number of nodes = %d\n", myTree.GetNodeCount());
bool flag = myTree.RemoveChild(tn1); //Child object name is "tn1"
printf("number of nodes = %d\n", myTree.GetNodeCount());
}
Remark
See Also
TreeNode::RemoveChildrenWithPrefix
Header to Include
origin.h
|