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


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

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


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

示例1: FindMatches

size_t BasicSearchTree::FindMatches(const wxString& s, std::set<size_t>& result, bool caseSensitive, bool is_prefix)
{
    // NOTE: Current algorithm is suboptimal, but certainly it's much better
    // than an exhaustive search.
    result.clear();
    wxString s2,curcmp,s3;
    SearchTreeNode* curnode = 0;
    BasicSearchTreeIterator it(this);
    SearchTreeItemsMap::iterator it2;

    bool matches;

    if (!caseSensitive)
        s2 = s.Lower();
    else
        s2 = s;

    while (!it.Eof())
    {
        matches = false;
        curnode = m_Nodes[*it];
        if (!curnode)
            break; // Error! Found a NULL Node
        if (curnode->m_Depth < s.length())
        {   // Node's string is shorter than S, therefore it CANNOT be a suffix
            // However, we can test if it does NOT match the current string.
            if (!curnode->m_Depth)
                matches = true;
            else
            {
                s3 = s2.substr(curnode->GetLabelStartDepth(),curnode->GetLabelLen());
                curcmp = curnode->GetLabel(this);
                if (!caseSensitive)
                    curcmp = curcmp.Lower();
                matches = (s3 == curcmp);
            }
        }
        else
        {
            if (curnode->GetLabelStartDepth() >= s2.length())
                matches = is_prefix;
            else
            {
                s3 = s2.substr(curnode->GetLabelStartDepth());
                curcmp = curnode->GetLabel(this);
                if (!caseSensitive)
                    curcmp = curcmp.Lower();
                matches = curcmp.StartsWith(s3);
            }

            if (matches)
            {
                // Begin items addition
                if (!is_prefix)
                {
                    // Easy part: Only one length to search
                    it2 = curnode->m_Items.find(s2.length());
                    if (it2 != curnode->m_Items.end())
                        result.insert(it2->second);
                }
                else
                {
                    for (it2 = curnode->m_Items.lower_bound(s2.length()); it2 != curnode->m_Items.end(); ++it2)
                    {
                        result.insert(it2->second);
                    }
                }
                matches = is_prefix;
                // End items addition
            }
        }
        it.FindNext(matches);
    }
    return result.size();
}
开发者ID:stahta01,项目名称:EmBlocks_old,代码行数:75,代码来源:searchtree.cpp


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