当前位置: 首页>>代码示例>>C++>>正文


C++ TreeNode::GetTreeNodeLeft方法代码示例

本文整理汇总了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);
}
开发者ID:rumjack,项目名称:fhscanhttplibrary,代码行数:25,代码来源:Tree.cpp

示例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);
}
开发者ID:rumjack,项目名称:fhscanhttplibrary,代码行数:47,代码来源:Tree.cpp

示例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);
    }
}
开发者ID:rumjack,项目名称:fhscanhttplibrary,代码行数:44,代码来源:Tree.cpp


注:本文中的TreeNode::GetTreeNodeLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。