本文整理汇总了C++中VNode::addChildNode方法的典型用法代码示例。如果您正苦于以下问题:C++ VNode::addChildNode方法的具体用法?C++ VNode::addChildNode怎么用?C++ VNode::addChildNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VNode
的用法示例。
在下文中一共展示了VNode::addChildNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sort
void
VSTree::split(VNode* _p_node_being_split, const SigEntry& _insert_entry, VNode* _p_insert_node)
{
#ifdef DEBUG_VSTREE
stringstream _ss;
_ss << "**********************split happen at "
<< _p_node_being_split->getFileLine() << endl;
_ss << _p_node_being_split->to_str() << endl;
Util::logging(_ss.str());
#endif
// first, add the new child node(if not leaf) or child entry(if leaf) to the full node.
bool just_insert_entry = (_p_insert_node == NULL);
if(just_insert_entry)
{
_p_node_being_split->addChildEntry(_insert_entry, true);
}
else
{
_p_node_being_split->addChildNode(_p_insert_node, true);
}
SigEntry entryA, entryB;
//BETTER: use hanming, xor result or the vector included angle to guess the distince.
//And then also use the farest two as seeds.
//
//two seeds to generate two new nodes.
//seedA kernel: the SigEntry with the minimal count of signature.
//seedB kernel: the SigEntry with the maximal count of signature.
int maxCount = 0; // record the minimal signature count.
int entryA_index = 0; // record the seedA kernel index.
for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
{
int currentCount = (int) _p_node_being_split->getChildEntry(i).getSigCount();
if(maxCount < currentCount)
{
maxCount = currentCount;
entryA_index = i;
}
}
entryA = _p_node_being_split->getChildEntry(entryA_index);
maxCount = 0;
int entryB_index = 0; // record the seedB kernel index.
for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
{
//NOTICE:I think xOR should be used here to choose the farest two
int currentCount = entryA.xOR(_p_node_being_split->getChildEntry(i));
//int currentCount = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
if(i != entryA_index && maxCount <= currentCount)
{
maxCount = currentCount;
entryB_index = i;
}
}
entryB = _p_node_being_split->getChildEntry(entryB_index);
// AEntryIndex: the entry index near seedA.
// BEntryIndex: the entry index near seedB.
std::vector<int> entryIndex_nearA, entryIndex_nearB;
entryIndex_nearA.clear();
entryIndex_nearB.clear();
entryIndex_nearA.push_back(entryA_index);
entryIndex_nearB.push_back(entryB_index);
int nearA_max_size, nearB_max_size;
bool nearA_tooSmall, nearB_tooSmall;
for(int i = 0; i < VNode::MAX_CHILD_NUM; i++)
{
if(i == entryA_index || i == entryB_index) continue;
//should guarantee that each new node has at least MIN_CHILD_NUM children.
nearA_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearB.size();
nearA_tooSmall = (nearA_max_size <= VNode::MIN_CHILD_NUM);
if(nearA_tooSmall)
{
for(; i < VNode::MAX_CHILD_NUM; i++)
{
if (i == entryA_index || i == entryB_index) continue;
entryIndex_nearA.push_back(i);
}
break;
}
nearB_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearA.size();
nearB_tooSmall = (nearB_max_size <= VNode::MIN_CHILD_NUM);
if(nearB_tooSmall)
{
for(; i < VNode::MAX_CHILD_NUM; i++)
{
if(i == entryA_index || i == entryB_index) continue;
entryIndex_nearB.push_back(i);
}
break;
}
//.........这里部分代码省略.........
示例2: split
void VSTree::split(VNode* _p_node_being_split, const SigEntry& _insert_entry, VNode* _p_insert_node)
{
//debug
// {
// stringstream _ss;
// _ss << "**********************split happen at "
// << _p_node_being_split->getFileLine() << endl;
// _ss << _p_node_being_split->to_str() << endl;
// Util::logging(_ss.str());
// }
// first, add the new child node(if not leaf) or child entry(if leaf) to the full node.
bool just_insert_entry = (_p_insert_node == NULL);
if (just_insert_entry)
{
_p_node_being_split->addChildEntry(_insert_entry, true);
}
else
{
_p_node_being_split->addChildNode(_p_insert_node, true);
}
SigEntry entryA, entryB;
/* two seeds to generate two new nodes.
* seedA kernel: the SigEntry with the minimal count of signature.
* seedB kernel: the SigEntry with the second minimal count of signature.
* */
int minCount = 0; // record the minimal signature count.
int entryA_index = 0; // record the seedA kernel index.
for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
{
int currentCount = (int) _p_node_being_split->getChildEntry(i).getSigCount();
if (minCount < currentCount)
{
minCount = currentCount;
entryA_index = i;
}
}
entryA = _p_node_being_split->getChildEntry(entryA_index);
minCount = 0;
int entryB_index = 0; // record the seedB kernel index.
for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
{
int currentCount = entryA.xEpsilen(_p_node_being_split->getChildEntry(i));
if (i != entryA_index && minCount <= currentCount)
{
minCount = currentCount;
entryB_index = i;
}
}
entryB = _p_node_being_split->getChildEntry(entryB_index);
// AEntryIndex: the entry index near seedA.
// BEntryIndex: the entry index near seedB.
std::vector<int> entryIndex_nearA, entryIndex_nearB;
entryIndex_nearA.clear();
entryIndex_nearB.clear();
entryIndex_nearA.push_back(entryA_index);
entryIndex_nearB.push_back(entryB_index);
/* just tmp variables, for more readibility */
int nearA_max_size, nearB_max_size;
bool nearA_tooSmall, nearB_tooSmall;
for (int i=0;i<VNode::MAX_CHILD_NUM;i++)
{
if (i == entryA_index || i == entryB_index) continue;
/* should guarantee that each new node has at least MIN_CHILD_NUM children. */
nearA_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearB.size();
nearA_tooSmall = (nearA_max_size <= VNode::MIN_CHILD_NUM);
if (nearA_tooSmall)
{
for (;i<VNode::MAX_CHILD_NUM;i++)
{
if (i == entryA_index || i == entryB_index) continue;
entryIndex_nearA.push_back(i);
}
break;
}
nearB_max_size = VNode::MAX_CHILD_NUM - entryIndex_nearA.size();
nearB_tooSmall = (nearB_max_size <= VNode::MIN_CHILD_NUM);
if (nearB_tooSmall)
{
for (;i<VNode::MAX_CHILD_NUM;i++)
{
if (i == entryA_index || i == entryB_index) continue;
entryIndex_nearB.push_back(i);
}
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));
//.........这里部分代码省略.........