本文整理汇总了C++中TreeNode::SetTreeNodeParentTree方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::SetTreeNodeParentTree方法的具体用法?C++ TreeNode::SetTreeNodeParentTree怎么用?C++ TreeNode::SetTreeNodeParentTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::SetTreeNodeParentTree方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TreeInsert
// -----------------------------------------------------------------------------
TreeNode* bTree::TreeInsert(HTTPCSTR str, TreeNode *ParentItem) {
if (ParentItem == NULL) {
if (root == NULL) {
TreeNode *newnode = new TreeNode(str, NULL);
newnode->SetTreeNodeParentTree(this);
root = newnode;
count++;
return (root);
}
else {
TreeNode *y = NULL;
TreeNode *x = root;
while (x != NULL) {
if (_tcscmp(x->GetTreeNodeName(), str) == 0) {
/* already Exists */
return (x);
}
y = x;
if (_tcscmp(str, x->GetTreeNodeName()) < 0)
x = x->GetTreeNodeLeft();
else
x = x->GetTreeNodeRight();
}
/* str doesn't yet exist in tree - add it in */
TreeNode *newnode = new TreeNode(str, y);
newnode->SetTreeNodeParentTree(this);
if (_tcscmp(str, y->GetTreeNodeName()) < 0) {
y->SetTreeNodeLeft(newnode);
}
else {
y->SetTreeNodeRight(newnode);
}
this->count++; /* Add an additional element to the tree counter */
return (newnode);
}
}
else {
TreeNode*newnode = ParentItem->GetTreeNodeChildTree()->TreeInsert(str, NULL);
return (newnode);
}
}