本文整理汇总了C++中BTreeNode::getChidNodes方法的典型用法代码示例。如果您正苦于以下问题:C++ BTreeNode::getChidNodes方法的具体用法?C++ BTreeNode::getChidNodes怎么用?C++ BTreeNode::getChidNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTreeNode
的用法示例。
在下文中一共展示了BTreeNode::getChidNodes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
BTreeNode * BPlusTree::GetLeafNode(int key)
{
BTreeNode * temp = root;
while(temp!= NULL)
{
if(temp->isLeaf())
{
return temp;
}
else
{
bool found = false;
for (unsigned int i = 0 ; i < temp->getkeys().size() ; i++)
{
if(key <= temp->getkeys()[i])
{
temp = temp->getChidNodes()[i];
found = true;
break;
}
}
if(!found)
{
temp = temp->getChidNodes()[temp->getChidNodes().size() -1];
}
}
}
return NULL;
}
示例2: splitParent
void BPlusTree::splitParent(BTreeNode * node , int key , BTreeNode * leftNode , BTreeNode * rightNode)
{
if(node == NULL)
{
root = new BTreeNode();
root->getkeys().push_back(key);
root->getChidNodes().push_back(leftNode);
root->getChidNodes().push_back(rightNode);
return;
}
node->insertIntoNode(key , leftNode , rightNode);
int splitIndex = node->getkeys().size()/2;
BTreeNode * left = node;
BTreeNode * right = new BTreeNode();
int keyToElevate = node->getkeys()[splitIndex];
right->copyContent(left , splitIndex+1 , node->getkeys().size()-1);
left->getkeys().resize(splitIndex);
left->getChidNodes().resize(splitIndex);
if(node->getparent() == NULL || node->getparent()->isFull())
splitParent(node->getparent() ,keyToElevate, left , right );
else
{
node->insertIntoNode(keyToElevate , left , right);
left->setParent(node);
right->setParent(node);
}
return;
}