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


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

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


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

示例1: to_str

std::string VSTree::to_str()
{
    //debug
    {
        stringstream _ss;
        _ss << "after build tree, root is:" << endl;
        _ss << this->getRoot()->to_str() << endl;
        Util::logging(_ss.str());
    }
	std::stringstream _ss;

	 std::queue<int> nodeFileLineQueue;
	 nodeFileLineQueue.push(this->getRoot()->getFileLine());
	 while(! nodeFileLineQueue.empty())
	 {
	        int currentNodeFileLine = nodeFileLineQueue.front();
	        nodeFileLineQueue.pop();
	        VNode* currentNodePtr = this->getNode(currentNodeFileLine);


	        _ss << currentNodePtr->to_str();

	        int childNum = currentNodePtr->getChildNum();
	        for(int i = 0; i < childNum; i ++)
	        {
	        	if(! currentNodePtr->isLeaf())
	        	{
                	int childNodeFileLine = currentNodePtr->getChildFileLine(i);
                	nodeFileLineQueue.push(childNodeFileLine);
	        	}
	       }
	 }

	return _ss.str();
}
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:35,代码来源:VSTree.cpp

示例2: sort


//.........这里部分代码省略.........
            break;
        }

         //calculate the distance from
         //the i-th child entry signature to seedA(or seedB).

		//NOTICE:we should expect that the candidate can be almost contained!
		//However, the precondition there are not too many 1s
        int disToSeedA = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
        int disToSeedB = entryB.xEpsilen(_p_node_being_split->getChildEntry(i));
        // choose the near one seed to add into
        if(disToSeedA <= disToSeedB)
        {
			 entryIndex_nearA.push_back(i);
        }
        else
        {
			 entryIndex_nearB.push_back(i);
        }
    }

    // then create a new node to act as BEntryIndex's father.
    VNode* newNodePtr = this->createNode();

#ifdef DEBUG_VSTREE
		stringstream _ss2;
		_ss2 << "new Node is :[" << newNodePtr->getFileLine() << "]" << endl;
		Util::logging(_ss2.str());
#endif
    // the old one acts as AEntryIndex's father.
    VNode* oldNodePtr = _p_node_being_split;

    // if the old node is leaf, set the new node as a leaf.
    if(oldNodePtr->isLeaf())
    {
        newNodePtr->setAsLeaf(true);
    }

	 //add all the entries in BEntryIndex into the new node child entry array,
	//and calculate the new node's entry.
    for(unsigned i = 0; i < entryIndex_nearB.size(); i++)
    {
        if(oldNodePtr->isLeaf())
        {
            newNodePtr->addChildEntry(oldNodePtr->getChildEntry(entryIndex_nearB[i]), false);
        }
        else
        {
			 //debug target 2
        	VNode* childPtr = oldNodePtr->getChild(entryIndex_nearB[i], *(this->node_buffer));
            newNodePtr->addChildNode(childPtr);
        }
    }
    newNodePtr->refreshSignature();

     //label the child being removed with -1,
     //and update the old node's entry.
    sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());

#ifdef DEBUG_VSTREE
    	stringstream _ss1;
    	{
    		_ss1 << "nearA: ";
    		for(unsigned i = 0; i < entryIndex_nearA.size(); i++)
    		{
    			_ss1 << entryIndex_nearA[i] << " ";
开发者ID:smilezcc,项目名称:gStore,代码行数:67,代码来源:VSTree.cpp

示例3: filterSig

//retrieve the candidate entity ID which signature can cover the _entity_bit_set, and add them to the  _p_id_list. 
void 
VSTree::retrieveEntity(const EntityBitSet& _entity_bit_set, IDList* _p_id_list)
{
	Util::logging("IN retrieveEntity");
    EntitySig filterSig(_entity_bit_set);
#ifdef DEBUG_VSTREE
	cerr << "the filter signature: " << filterSig.to_str() << endl;
#endif
    queue<int> nodeQueue; //searching node file line queue.

    //debug
    {
        stringstream _ss;
        _ss << "filterSig=" << Signature::BitSet2str(filterSig.entityBitSet) << endl;
        Util::logging(_ss.str());
    }

    const SigEntry& root_entry = (this->getRoot())->getEntry();
    Util::logging("Get Root Entry");

    if(root_entry.cover(filterSig))
    {
        nodeQueue.push(this->getRoot()->getFileLine());
    	Util::logging("root cover the filter_sig");
    }
    else
    {
    	Util::logging("warning: root is not cover the filter_sig");
    }

    //debug
//    {
//    	Util::logging(this->getRoot()->to_str());
//    	Util::logging("Before BFS");
//    }

	//using BFS algorithm to traverse the VSTree and retrieve the entry.
    while (!nodeQueue.empty())
    {
        int currentNodeFileLine = nodeQueue.front();
        nodeQueue.pop();
        VNode* currentNodePtr = this->getNode(currentNodeFileLine);

        int childNum = currentNodePtr->getChildNum();

        //debug
//        {
//        	std::stringstream _ss;
//        	_ss << "childNum of ["
//        		<< currentNodePtr->getFileLine()
//        		<< "] is " << childNum << endl;
//
//        	for (int i=0;i<childNum;i++)
//        	{
//        	    _ss << currentNodePtr->getChildFileLine(i) << " ";
//        	}
//        	_ss << endl;
//
//        	Util::logging(_ss.str());
//        }

		int valid = 0;
        for (int i = 0; i < childNum; i++)
        {
            const SigEntry& entry = currentNodePtr->getChildEntry(i);

#ifdef DEBUG_VSTREE
			//cerr << "current entry: " << entry.to_str() << endl;
#endif

            if (entry.cover(filterSig))
            {
				valid++;
                if (currentNodePtr->isLeaf())
                {
                    // if leaf node, add the satisfying entries' entity id to result list.
                    _p_id_list->addID(entry.getEntityId());

                    //debug
//                    {
//                    stringstream _ss;
//                    _ss << "child_" << i << " cover filter sig" << endl;
//                    _ss << Signature::BitSet2str(entry.getEntitySig().entityBitSet)<< endl;
//                    Util::logging(_ss.str());
//                    }
                }
                else
                {
                    // if non-leaf node, add the child node pointer to the searching queue.
                	//VNode* childPtr = currentNodePtr->getChild(i, *(this->node_buffer));
                    // if non-leaf node, add the child node file line to the searching queue.
                	int childNodeFileLine = currentNodePtr->getChildFileLine(i);
                	nodeQueue.push(childNodeFileLine);

                    //debug
//                    {
//                        stringstream _ss;
//                        _ss << "child[" << childPtr->getFileLine() << "] cover filter sig" << endl;
//                        Util::logging(_ss.str());
//.........这里部分代码省略.........
开发者ID:smilezcc,项目名称:gStore,代码行数:101,代码来源:VSTree.cpp

示例4: split


//.........这里部分代码省略.........
            break;
        }

        /* calculate the distance from
         * the i-th child entry signature to seedA(or seedB).*/

        /*debug target 1*/
        int disToSeedA = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
        int disToSeedB = entryB.xEpsilen(_p_node_being_split->getChildEntry(i));
        // choose the near one seed to add into
        if (disToSeedA <= disToSeedB)
        {
        	 entryIndex_nearA.push_back(i);
        }
        else
        {
        	 entryIndex_nearB.push_back(i);
        }
    }

    // then create a new node to act as BEntryIndex's father.
    VNode* newNodePtr = this->createNode();

    //debug
//    {
//    	stringstream _ss;
//    	_ss << "new Node is :[" << newNodePtr->getFileLine() << "]" << endl;
//    	Util::logging(_ss.str());
//    }
    // the old one acts as AEntryIndex's father.
    VNode* oldNodePtr = _p_node_being_split;

    // if the old node is leaf, set the new node as a leaf.
    if (oldNodePtr->isLeaf())
    {
        newNodePtr->setAsLeaf(true);
    }

    /* add all the entries in BEntryIndex into the new node child entry array,
    and calculate the new node's entry.*/
    for (unsigned i=0;i<entryIndex_nearB.size();i++)
    {
        if (oldNodePtr->isLeaf())
        {
            newNodePtr->addChildEntry(oldNodePtr->getChildEntry(entryIndex_nearB[i]), false);
        }
        else
        {
        	 /*debug target 2*/
        	VNode* childPtr = oldNodePtr->getChild(entryIndex_nearB[i], *(this->node_buffer));
            newNodePtr->addChildNode(childPtr);
        }
    }
    newNodePtr->refreshSignature();

    /* label the child being removed with -1,
     * and update the old node's entry.*/
    std::sort(entryIndex_nearA.begin(), entryIndex_nearA.end(), less<int>());

    //debug
//    {
//    	stringstream _ss;
//    	{
//    		_ss << "nearA: ";
//    		for(int i = 0; i < entryIndex_nearA.size(); i ++)
//    		{
开发者ID:zhangxiaoyang,项目名称:gStore,代码行数:67,代码来源:VSTree.cpp


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