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


C++ VNode::isFull方法代码示例

本文整理汇总了C++中VNode::isFull方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::isFull方法的具体用法?C++ VNode::isFull怎么用?C++ VNode::isFull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VNode的用法示例。


在下文中一共展示了VNode::isFull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

//insert an new Entry, whose entity doesn't exist before 
bool 
VSTree::insertEntry(const SigEntry& _entry)
{

	//choose the best leaf node to insert the _entry 
    VNode* choosedNodePtr = this->chooseNode(this->getRoot(), _entry);

#ifdef DEBUG_VSTREE
		if (_entry.getEntityId() == 4000001)
		{
			stringstream _ss;
			if (choosedNodePtr)
			{
				_ss << "insert " << _entry.getEntityId()
					<< " into [" << choosedNodePtr->getFileLine() << "],\t";
				_ss << "whose childnum is " << choosedNodePtr->getChildNum() << endl;
			}
			else
			{
				_ss << "insert " << _entry.getEntityId() << " , can not choose a leaf node to insert entry. @VSTree::insert" << endl;
			}
			Util::logging(_ss.str());
		}
#endif

    if (choosedNodePtr == NULL)
    {
        cerr << "error, can not choose a leaf node to insert entry. @VSTree::insert" << endl;
        return false;
    }

    if (choosedNodePtr->isFull())
    {
		 //if the choosed leaf node to insert is full, the node should be split.
        this->split(choosedNodePtr, _entry, NULL);

        //debug
//        if (!choosedNodePtr->checkState())
//        {
//            stringstream _ss;
//            _ss << "node " << choosedNodePtr->getFileLine() << " childFileLine error. after split" << endl;
//            Util::logging(_ss.str());
//        }
    }
    else
    {
        choosedNodePtr->addChildEntry(_entry, false);
        choosedNodePtr->refreshAncestorSignature(*(this->node_buffer));

        //debug
//        if (!choosedNodePtr->checkState())
//        {
//            stringstream _ss;
//            _ss << "node " << choosedNodePtr->getFileLine() << " childFileLine error. after addChildEntry" << endl;
//            _ss <<"child num=" << choosedNodePtr->getChildNum() << endl;
//            _ss <<"node num=" << this->node_num << " entry num=" << this->entry_num << endl;
//            Util::logging(_ss.str());
//        }

        // update the entityID2FileLineMap.
        this->entityID2FileLineMap[_entry.getEntityId()] = choosedNodePtr->getFileLine();
    }
    this->entry_num ++;

    return true;
}
开发者ID:smilezcc,项目名称:gStore,代码行数:67,代码来源:VSTree.cpp

示例2: sort


//.........这里部分代码省略.........

    		_ss1 << "nearB: ";
    		for(unsigned i = 0; i < entryIndex_nearB.size(); i++)
    		{
    			_ss1 << entryIndex_nearB[i] << " ";
    		}
    		_ss1 << endl;
    	}
    	Util::logging(_ss1.str());
#endif

    for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
    {
        oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
        oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
    }
    oldNodePtr->setChildNum(entryIndex_nearA.size());
    oldNodePtr->refreshSignature();

    int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
    // full node's father pointer.
    VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
    if(oldNodePtr->isRoot())
    {
         //if the old node is root,
		 //split the root, create a new root,
         //and the tree height will be increased.
        VNode* RootNewPtr = this->createNode();

         //change the old root node to not-root node,
         //and set the RootNew to root node.
        oldNodePtr->setAsRoot(false);
        RootNewPtr->setAsRoot(true);

         //set the split two node(old node and new node) as the new root's child,
         //and update signatures.
        RootNewPtr->addChildNode(oldNodePtr);
        RootNewPtr->addChildNode(newNodePtr);
        RootNewPtr->refreshSignature();

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            Util::logging(_ss.str());
//        }

         //should keep the root node always being
         //at the first line(line zero) of the tree node file.
        this->swapNodeFileLine(RootNewPtr, oldNodePtr);
        this->height++;

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            _ss << Signature::BitSet2str(oldNodePtr->getEntry().getEntitySig().entityBitSet) << endl;
//            _ss << RootNewPtr->to_str() << endl;
//            Util::logging(_ss.str());
//        }
    }
    else
    {
         //if the (OldNode) is not Root,
         //change the old node's signature to A's signature.
    	oldNodeFatherPtr->setChildEntry(oldNode_index, oldNodePtr->getEntry());


        if(oldNodeFatherPtr->isFull())
        {
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
            this->split(oldNodeFatherPtr, newNodePtr->getEntry(), newNodePtr);
        }
        else
        {
        	oldNodeFatherPtr->addChildNode(newNodePtr);
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
        }
    }

    //debug
//    if (!oldNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << oldNodePtr->getFileLine() << " childFileLine error. oldNode when split" << endl;
//        Util::logging(_ss.str());
//    }
//    if (!newNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << newNodePtr->getFileLine() << " childFileLine error. newNode when split" << endl;
//        Util::logging(_ss.str());
//    }

    // update the entityID2FileLineMap by these two nodes.
    this->updateEntityID2FileLineMap(oldNodePtr);
    this->updateEntityID2FileLineMap(newNodePtr);
}
开发者ID:smilezcc,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp

示例3: split


//.........这里部分代码省略.........
//
//    		_ss << "nearB: ";
//    		for(int i = 0; i < entryIndex_nearB.size(); i ++)
//    		{
//    			_ss << entryIndex_nearB[i] << " ";
//    		}
//    		_ss << endl;
//    	}
//    	Util::logging(_ss.str());
//    }

    for (unsigned i=0;i<entryIndex_nearA.size();i++)
    {
        oldNodePtr->setChildEntry(i, oldNodePtr->getChildEntry(entryIndex_nearA[i]));
        oldNodePtr->setChildFileLine(i, oldNodePtr->getChildFileLine(entryIndex_nearA[i]));
    }
    oldNodePtr->setChildNum(entryIndex_nearA.size());
    oldNodePtr->refreshSignature();

    int oldNode_index = oldNodePtr->getIndexInFatherNode(*(this->node_buffer));
    // full node's father pointer.
    VNode* oldNodeFatherPtr = oldNodePtr->getFather(*(this->node_buffer));
    if (oldNodePtr->isRoot())
    {
        /* if the old node is root,
         * split the root, create a new root,
         * and the tree height will be increased.*/
        VNode* RootNewPtr = this->createNode();

        /* change the old root node to not-root node,
         * and set the RootNew to root node.*/
        oldNodePtr->setAsRoot(false);
        RootNewPtr->setAsRoot(true);

        /* set the split two node(old node and new node) as the new root's child,
         * and update signatures.*/
        RootNewPtr->addChildNode(oldNodePtr);
        RootNewPtr->addChildNode(newNodePtr);
        RootNewPtr->refreshSignature();

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "before swap file line, two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            Util::logging(_ss.str());
//        }

        /* should keep the root node always being
         * at the first line(line zero) of the tree node file.*/
        this->swapNodeFileLine(RootNewPtr, oldNodePtr);
        this->height ++;

        //debug
//        {
//            stringstream _ss;
//            _ss << "create new root:" << endl;
//            _ss << "two sons are: " << oldNodePtr->getFileLine() << " " << newNodePtr->getFileLine() << endl;
//            _ss << Signature::BitSet2str(oldNodePtr->getEntry().getEntitySig().entityBitSet) << endl;
//            _ss << RootNewPtr->to_str() << endl;
//            Util::logging(_ss.str());
//        }
    }
    else
    {
        /* if the (OldNode) is not Root,
         * change the old node's signature to A's signature.*/
    	oldNodeFatherPtr->setChildEntry(oldNode_index, oldNodePtr->getEntry());


        if (oldNodeFatherPtr->isFull())
        {
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
            this->split(oldNodeFatherPtr, newNodePtr->getEntry(), newNodePtr);
        }
        else
        {
        	oldNodeFatherPtr->addChildNode(newNodePtr);
        	oldNodeFatherPtr->refreshAncestorSignature(*(this->node_buffer));
        }
    }

    //debug
//    if (!oldNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << oldNodePtr->getFileLine() << " childFileLine error. oldNode when split" << endl;
//        Util::logging(_ss.str());
//    }
//    if (!newNodePtr->checkState())
//    {
//        stringstream _ss;
//        _ss << "node " << newNodePtr->getFileLine() << " childFileLine error. newNode when split" << endl;
//        Util::logging(_ss.str());
//    }

    // update the entityID2FileLineMap by these two nodes.
    this->updateEntityID2FileLineMap(oldNodePtr);
    this->updateEntityID2FileLineMap(newNodePtr);
}
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp


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