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


C++ SearchTreeNode::UpdateItems方法代码示例

本文整理汇总了C++中SearchTreeNode::UpdateItems方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchTreeNode::UpdateItems方法的具体用法?C++ SearchTreeNode::UpdateItems怎么用?C++ SearchTreeNode::UpdateItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchTreeNode的用法示例。


在下文中一共展示了SearchTreeNode::UpdateItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SplitBranch

nSearchTreeNode BasicSearchTree::SplitBranch(nSearchTreeNode n,size_t depth)
{
    if (!n || !m_Nodes[n] || m_Nodes[n]->GetDepth()==depth)
        return n;
    // for !n it returns the rootnode
    // for !m_Nodes[n], it fails by returning n.
    // for m_Nodes[n]->GetDepth()==depth, it's a special case (given position is a node)
    // so we just return n.

    SearchTreeNode* child = m_Nodes[n];

    nSearchTreeNode old_parent = child->GetParent();

    // Create new node "middle", add it to old_parent in place of child.

    // Calculate the parent offset and the new labels' parameters.
    size_t parent_offset = depth - child->GetLabelStartDepth();
    nSearchTreeLabel labelno = child->GetLabelNo();

    unsigned int oldlabelstart = child->GetLabelStart();
    unsigned int oldlabellen = child->GetLabelLen();

    unsigned int middle_start = oldlabelstart;
    unsigned int middle_len = parent_offset;

    unsigned int child_start = middle_start + middle_len;
    unsigned int child_len = oldlabellen - middle_len;

    wxChar middle_char = m_Labels[labelno][middle_start];
    wxChar child_char = m_Labels[labelno][child_start];

    // Now we're ready to create the middle node and update accordingly

    SearchTreeNode* newnode = CreateNode(depth,old_parent,labelno,middle_start,middle_len);
    m_Nodes.push_back(newnode);
    nSearchTreeNode middle = m_Nodes.size() - 1;

    // Add child to middle
    child->SetParent(middle);
    child->SetLabel(labelno,child_start,child_len);
    child->RecalcDepth(this);
    newnode->m_Children[child_char]=n;
    child->UpdateItems(this);

    // Add middle to old_parent
    m_Nodes[old_parent]->m_Children[middle_char]=middle;

    return middle;
}
开发者ID:stahta01,项目名称:EmBlocks_old,代码行数:49,代码来源:searchtree.cpp


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