本文整理汇总了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();
}
示例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] << " ";
示例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());
//.........这里部分代码省略.........
示例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 ++)
// {