本文整理汇总了C++中BTreeNode::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ BTreeNode::remove方法的具体用法?C++ BTreeNode::remove怎么用?C++ BTreeNode::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTreeNode
的用法示例。
在下文中一共展示了BTreeNode::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
BTreeNode* InternalNode::remove(int value) {
BTreeNode *leaf = NULL;
for(int i = 0; i < count; i++) {
if(i == 0 && value <= keys[i]) leaf = children[0];
if(i == count - 1 && value >= keys[i]) leaf = children[i];
if(value >= keys[i] && value < keys[i+1]) leaf = children[i];
if(leaf != NULL) {
leaf = leaf->remove(value);
//keys[i] = children[i]->getMinimum();
for(int i = 0; i < count; i++) {
if(children[i]->getCount() == 0) {
for(; i < count - 1; i++) {
children[i] = children[i + 1];
keys[i] = keys[i + 1];
}
--count;
break;
}
}
}
}
this->tryBorrowing();
this->prune();
if(parent == NULL && this->count == 1) return this->children[0] ;
else return this;
} // InternalNode::remove(int value)
示例2: remove
void BTree::remove(int k)
{
if (!root)
{
cout << "The tree is empty\n";
return;
}
// Call the remove function for root
root->remove(k);
// If the root node has 0 keys, make its first child as the new root
// if it has a child, otherwise set root as NULL
if (root->n==0)
{
BTreeNode *tmp = root;
if (root->leaf)
root = NULL;
else
root = root->C[0];
// Free the old root
delete tmp;
}
return;
}
示例3: remove
void BTree::remove(string name) {
//DELETE AT LEAF
BTreeNode* leaf = findNode(root, name);
if(leaf->find(name,EXACT)==NOTFOUND){
cout << "TARGET NOT FOUND" << endl;
return;
}
cout << "Found TARGET. Now deleting it. "<< endl;
leaf=leaf->remove(name);
cout << "DELETE SUCESSFULLY. Now ADJUSTING ROOT" <<endl;
AdjustingRoot(leaf);
}