本文整理汇总了C++中SearchTreeNode::GetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchTreeNode::GetParent方法的具体用法?C++ SearchTreeNode::GetParent怎么用?C++ SearchTreeNode::GetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchTreeNode
的用法示例。
在下文中一共展示了SearchTreeNode::GetParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindPrevSibling
bool BasicSearchTreeIterator::FindPrevSibling()
{
if (!IsValid())
return false;
if (!m_CurNode /* || !m_Stack.size() */)
m_Eof = true;
SearchTreeNode* node = m_Tree->GetNode(m_CurNode);
if (!node)
return false;
wxChar ch = node->GetChar(m_Tree);
node = node->GetParent(m_Tree);
if (!node)
return false;
SearchTreeLinkMap* the_map = &node->m_Children;
SearchTreeLinkMap::iterator it = the_map->find(ch);
if (it == the_map->end())
m_Eof = true;
else
{
if (it == the_map->begin())
m_Eof = true;
else
{
--it;
m_CurNode = it->second;
}
}
return true;
}
示例2: 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;
}
示例3: FindSibling
bool BasicSearchTreeIterator::FindSibling(char ch)
{
if(!IsValid())
return false;
if(!m_CurNode /* || !m_Stack.size() */)
m_eof = true;
SearchTreeNode* node = m_pTree->GetNode(m_CurNode);
if(!node)
return false;
node = node->GetParent(m_pTree);
if(!node)
return false;
SearchTreeLinkMap* the_map = &node->m_Children;
SearchTreeLinkMap::iterator it = the_map->find(ch);
if(it == the_map->end())
m_eof = true;
else
{
m_CurNode = it->second;
}
return true;
}