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