本文整理汇总了C++中InternalNode::updateMinimums方法的典型用法代码示例。如果您正苦于以下问题:C++ InternalNode::updateMinimums方法的具体用法?C++ InternalNode::updateMinimums怎么用?C++ InternalNode::updateMinimums使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternalNode
的用法示例。
在下文中一共展示了InternalNode::updateMinimums方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
InternalNode* InternalNode::insert(int value)
{
// students must write this
updateMinimums();
sort();
//updateMinimums();
//cout << "Starting InternalNode insert: " << value << endl;
//search keys for position to insert, count - 1 because elements start at 0
int searchKey = count-1;
for(int i = count-1; keys[searchKey] > value && i > 0; i--){
//cout << keys[searchKey] << " > " << value << endl;
searchKey--;
}
BTreeNode* leafSplit = children[searchKey]->insert(value);
updateMinimums();
sort();
//updateMinimums();
//for(int i = 6; i >= 0; i--)
// cout << "Keys[" << i << "]: " << keys[i] << endl;
if(!leafSplit){
//cout << "no leaf split" << endl;
return NULL;
}
if(leafSplit && count < internalSize){
//add here
//cout << "InternalNode Insert Here" << endl;
//cout << "InternalNode leafSplit has min: " << leafSplit->getMinimum() << endl;
keys[count] = leafSplit->getMinimum();
children[count] = leafSplit;
count++;
updateMinimums();
sort();
//updateMinimums();
return NULL;
}
else if(leftSibling && leftSibling->getCount() < internalSize){
//addToLeft(internalSplit)
//cout << "NEED TO SHARE TO LEFT" << endl;
// cout << "Adding to left internal" << endl;
((InternalNode*)leftSibling)->insert(children[0]);
((InternalNode*)leftSibling)->updateMinimums();
((InternalNode*)leftSibling)->sort();
//((InternalNode*)leftSibling)->updateMinimums();
count--;
for(int i = 0; i < count; i++)
{
children[i] = children[i + 1];
keys[i] = keys[i + 1];
}
children[count] = leafSplit;
keys[count] = leafSplit->getMinimum();
count++;
updateMinimums();
sort();
//updateMinimums();
//cout << "leafSplit min: " << leafSplit->getMinimum() << endl;
leafSplit->setParent(this);
if(parent)
parent->findMin(this);
return NULL;
}
else if(rightSibling && rightSibling->getCount() < internalSize){
//addtoRight
if(keys[count-1] > leafSplit->getMinimum()){
//cout << "Internal Passing to right: " << keys[count-1] << endl;
((InternalNode*) rightSibling)->insert(children[count-1]);
((InternalNode*) rightSibling)->updateMinimums();
((InternalNode*) rightSibling)->sort();
children[count-1] = leafSplit;
updateMinimums();
sort();
if(((InternalNode*) rightSibling)->parent){
(((InternalNode*) rightSibling)->parent)->updateMinimums();
(((InternalNode*) rightSibling)->parent)->sort();
}
}
return NULL;
}
else if(leafSplit){
//cout << "Internal Split" << endl;
InternalNode* newRight = new InternalNode(internalSize, leafSize, parent, this, rightSibling);
BTreeNode* oldRight = getRightSibling();
if(rightSibling){
oldRight->setLeftSibling(newRight);
newRight->setRightSibling(oldRight);
newRight->setLeftSibling(this);
}
rightSibling = newRight;
int rightCount;
for(int i = (internalSize+1) / 2; i < internalSize; i++){
//cout << "i: " << i << endl;
//.........这里部分代码省略.........