本文整理汇总了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();
}