当前位置: 首页>>代码示例>>C++>>正文


C++ BTreeNode::remove方法代码示例

本文整理汇总了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)
开发者ID:zj9205,项目名称:ECS60,代码行数:35,代码来源:InternalNode.cpp

示例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;
}
开发者ID:harveson,项目名称:nvmalloc,代码行数:26,代码来源:btree_new_wrd_trans.c

示例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); 
}
开发者ID:confidential96,项目名称:CS130A-Final-Project,代码行数:12,代码来源:BTree.cpp


注:本文中的BTreeNode::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。