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


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

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


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

示例1:

//choose the best leaf node to insert the _entry, return the choosed leaf node's pointer.  Recursion!
VNode* 
VSTree::chooseNode(VNode* _p_node, const SigEntry& _entry)
{
    if(_p_node->isLeaf())
    {
        return _p_node;
    }
    else
    {
		int minDis = Signature::ENTITY_SIG_LENGTH + 1;
        //int maxDis = Signature::ENTITY_SIG_LENGTH + 1;
        int candidateIndex[VNode::MAX_CHILD_NUM];
        int candidateNum = 0;
        int childNum = _p_node->getChildNum();
        for(int i = 0; i < childNum; i++)
        {
            int curDis = _p_node->getChildEntry(i).xEpsilen(_entry);
            if(minDis >= curDis)
            {
                if(minDis > curDis)
                {
                    minDis = curDis;
                    candidateNum = 0;
                }
                candidateIndex[candidateNum++] = i;
            }
        }

		//NOTICE: the basic idea is to place similar signatures together?(the smaller num?)
		//BETTER: recursion is too costly , and the performance maybe not so good

		minDis = Signature::ENTITY_SIG_LENGTH + 1;
        //maxDis = Signature::ENTITY_SIG_LENGTH + 1;
        VNode* ret = NULL;
        for(int i = 0; i < candidateNum; i++)
        {
        	int child_i = candidateIndex[i];
        	VNode* p_child = _p_node->getChild(child_i, *(this->node_buffer));
			//Recursion 
            VNode *candidateLeafPtr = this->chooseNode(p_child, _entry);
            int curDis = candidateLeafPtr->getEntry().xEpsilen(_entry);

            if(curDis == 0)
            {
                return candidateLeafPtr;
            }

            if(minDis > curDis)
            {
                minDis = curDis;
                ret = candidateLeafPtr;
            }
        }

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

示例2: chooseNode

/* choose the best leaf node to insert the _entry,
 * return the choosed leaf node's pointer.
 * Recursion function! */
VNode* VSTree::chooseNode(VNode* _p_node, const SigEntry& _entry)
{
    if (_p_node->isLeaf())
    {
        return _p_node;
    }
    else
    {
        int minDis = Signature::ENTITY_SIG_LENGTH + 1;
        int candidateIndex[VNode::MAX_CHILD_NUM];
        int candidateNum = 0;
        int childNum = _p_node->getChildNum();
        for (int i=0;i<childNum;i++)
        {
            int curDis = _p_node->getChildEntry(i).xEpsilen(_entry);
            if (minDis >= curDis)
            {
                if (minDis > curDis)
                {
                    minDis = curDis;
                    candidateNum = 0;
                }
                candidateIndex[candidateNum ++] = i;
            }
        }

        minDis = Signature::ENTITY_SIG_LENGTH + 1;
        VNode* ret = NULL;
        for (int i=0;i<candidateNum;i++)
        {
        	int child_i = candidateIndex[i];
        	VNode* p_child = _p_node->getChild(child_i, *(this->node_buffer));
        	/* Recursion */
            VNode *candidateLeafPtr = this->chooseNode(p_child, _entry);
            int curDis = candidateLeafPtr->getEntry().xEpsilen(_entry);

            if (curDis == 0)
            {
                return candidateLeafPtr;
            }

            if (minDis > curDis)
            {
                minDis = curDis;
                ret = candidateLeafPtr;
            }
        }

        return ret;
    }
}
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:54,代码来源:VSTree.cpp

示例3: 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

示例4: if


//.........这里部分代码省略.........
		}
		else
		{
			_child->setChildFileLine(_entry_index, p->getChildFileLine(0));
			_child->setChildEntry(_entry_index, p->getChildEntry(0));
			tmp = p->getChild(0, *(this->node_buffer));
			tmp->setFatherFileLine(child_no);
			for(int i = 1; i < n; ++i)
			{
				tmp = p->getChild(i, *(this->node_buffer));
				//cout<<i<<"   "<<_child->getChildNum()<<endl;
				_child->addChildNode(tmp);
				//_child->setChildNum(cn+i);
				//tmp->setFatherFileLine(child_no);
			}
		}
		this->removeNode(p);
		_child->refreshSignature();
		//recursive:to remove child index+1 in father
		this->coalesce(_father, _child_index+1);
		break;

	case 2:    //move one from right
		_child->setChildFileLine(_entry_index, p->getChildFileLine(n-1));
		_child->setChildEntry(_entry_index, p->getChildEntry(n-1));
		_child->refreshSignature();
		if(!_child->isLeaf())
		{
			tmp = p->getChild(n-1, *(this->node_buffer));
			tmp->setFatherFileLine(child_no);
		}
		p->removeChild(n-1);
		p->refreshSignature();
		_father->setChildEntry(_child_index, _child->getEntry());
		_father->setChildEntry(_child_index+1, p->getEntry());
		_father->refreshAncestorSignature(*(this->node_buffer));
		break;

	case 3:    //union left to this
		if(_child->isLeaf())
		{
			_child->setChildFileLine(_entry_index, p->getChildFileLine(0));
			_child->setChildEntry(_entry_index, p->getChildEntry(0));
			for(int i = 1; i < n; ++i)
			{
				_child->setChildFileLine(cn+i-1, p->getChildFileLine(i));
				_child->addChildEntry(p->getChildEntry(i));
			}
		}
		else
		{
			_child->setChildFileLine(_entry_index, p->getChildFileLine(0));
			_child->setChildEntry(_entry_index, p->getChildEntry(0));
			tmp = p->getChild(0, *(this->node_buffer));
			tmp->setFatherFileLine(child_no);
			for(int i = 1; i < n; ++i)
			{
				tmp = p->getChild(i, *(this->node_buffer));
				//cout<<i<<"   "<<_child->getChildNum()<<endl;
				_child->addChildNode(tmp);
				//_child->setChildNum(cn+i);
				//tmp->setFatherFileLine(child_no);
			}
		}
		this->removeNode(p);
		_child->refreshSignature();
开发者ID:bnu05pp,项目名称:gStoreD,代码行数:67,代码来源:VSTree.cpp

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