本文整理汇总了C++中TreeNode::GetTreeNodeLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::GetTreeNodeLeft方法的具体用法?C++ TreeNode::GetTreeNodeLeft怎么用?C++ TreeNode::GetTreeNodeLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::GetTreeNodeLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
TreeNode *bTree::TreeExistItem(HTTPCSTR lpTreeItemName) {
TreeNode *x;
if (root == NULL) {
return (NULL);
}
/* search the tree */
x = root;
while (x != NULL) {
int ret = _tcscmp(lpTreeItemName,x->GetTreeNodeName());
if (ret == 0) {
return (x);
}
else {
if (ret < 0) {
x = x->GetTreeNodeLeft();
}
else {
x = x->GetTreeNodeRight();
}
}
}
return (NULL);
}
示例2: if
TreeNode *bTree::GetTreeNodeItemID(int value) {
int n = value + 1; /* Cheat to allow the counter to be 0 */
if ((count < n) || (n <= 0)) {
return (NULL);
}
TreeNode *node = root;
int total = 0;
#define NLEFT node->GetTreeNodeLeft()->GetTreeNodeCount() +1
#define NRIGHT node->GetTreeNodeRight()->GetTreeNodeCount() +1
while ((node != NULL) && (total < n)) {
if (node->GetTreeNodeLeft()) {
if (NLEFT + total >= n) {
node = node->GetTreeNodeLeft();
}
else {
total += NLEFT; // add nodes from left side
total++; // Add current node
if (total == n) {
return (node);
}
else {
node = node->GetTreeNodeRight();
}
}
}
else if (node->GetTreeNodeRight()) {
total++;
if (total == n) {
return (node);
}
else {
node = node->GetTreeNodeRight();
}
}
else {
total++;
if (total == n) {
return (node);
}
else {
/* FATAL - ##CRITICAL UNEXPECTED ERROR##: BAD IMPLEMENTATION? */
return (NULL);
}
}
}
return (NULL);
}
示例3: 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);
}
}