本文整理汇总了C++中VNode::getIndexInFatherNode方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::getIndexInFatherNode方法的具体用法?C++ VNode::getIndexInFatherNode怎么用?C++ VNode::getIndexInFatherNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::getIndexInFatherNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort
//.........这里部分代码省略.........
//label the child being removed with -1,
//and update the old node's entry.
sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());
#ifdef DEBUG_VSTREE
stringstream _ss1;
{
_ss1 << "nearA: ";
for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
{
_ss1 << entryIndex_nearA[i] << " ";
}
_ss1 << endl;
_ss1 << "nearB: ";
for(unsigned i = 0; i < entryIndex_nearB.size(); i++)
{
_ss1 << entryIndex_nearB[i] << " ";
}
_ss1 << endl;
}
Util::logging(_ss1.str());
#endif
for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
{
oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
}
oldNodePtr->setChildNum(entryIndex_nearA.size());
oldNodePtr->refreshSignature();
int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
// full node's father pointer.
VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
if(oldNodePtr->isRoot())
{
//if the old node is root,
//split the root, create a new root,
//and the tree height will be increased.
VNode* RootNewPtr = this->createNode();
//change the old root node to not-root node,
//and set the RootNew to root node.
oldNodePtr->setAsRoot(false);
RootNewPtr->setAsRoot(true);
//set the split two node(old node and new node) as the new root's child,
//and update signatures.
RootNewPtr->addChildNode(oldNodePtr);
RootNewPtr->addChildNode(newNodePtr);
RootNewPtr->refreshSignature();
//debug
// {
// stringstream _ss;
// _ss << "create new root:" << endl;
// _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
// Util::logging(_ss.str());
// }
//should keep the root node always being
//at the first line(line zero) of the tree node file.
this->swapNodeFileLine(RootNewPtr, oldNodePtr);
this->height++;
示例2: split
//.........这里部分代码省略.........
/* label the child being removed with -1,
* and update the old node's entry.*/
std::sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());
//debug
// {
// stringstream _ss;
// {
// _ss << "nearA: ";
// for(int i = 0; i < entryIndex_nearA.size(); i ++)
// {
// _ss << entryIndex_nearA[i] << " ";
// }
// _ss << endl;
//
// _ss << "nearB: ";
// for(int i = 0; i < entryIndex_nearB.size(); i ++)
// {
// _ss << entryIndex_nearB[i] << " ";
// }
// _ss << endl;
// }
// Util::logging(_ss.str());
// }
for (unsigned i=0;i<entryIndex_nearA.size();i++)
{
oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
}
oldNodePtr->setChildNum(entryIndex_nearA.size());
oldNodePtr->refreshSignature();
int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
// full node's father pointer.
VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
if (oldNodePtr->isRoot())
{
/* if the old node is root,
* split the root, create a new root,
* and the tree height will be increased.*/
VNode* RootNewPtr = this->createNode();
/* change the old root node to not-root node,
* and set the RootNew to root node.*/
oldNodePtr->setAsRoot(false);
RootNewPtr->setAsRoot(true);
/* set the split two node(old node and new node) as the new root's child,
* and update signatures.*/
RootNewPtr->addChildNode(oldNodePtr);
RootNewPtr->addChildNode(newNodePtr);
RootNewPtr->refreshSignature();
//debug
// {
// stringstream _ss;
// _ss << "create new root:" << endl;
// _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
// Util::logging(_ss.str());
// }
/* should keep the root node always being
* at the first line(line zero) of the tree node file.*/
this->swapNodeFileLine(RootNewPtr, oldNodePtr);
this->height ++;