本文整理汇总了C++中TreeType::MaxNumChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeType::MaxNumChildren方法的具体用法?C++ TreeType::MaxNumChildren怎么用?C++ TreeType::MaxNumChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeType
的用法示例。
在下文中一共展示了TreeType::MaxNumChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckFills
void CheckFills(const TreeType& tree)
{
if (tree.IsLeaf())
{
BOOST_REQUIRE(tree.Count() >= tree.MinLeafSize() || tree.Parent() == NULL);
BOOST_REQUIRE(tree.Count() <= tree.MaxLeafSize());
}
else
{
for (size_t i = 0; i < tree.NumChildren(); i++)
{
BOOST_REQUIRE(tree.NumChildren() >= tree.MinNumChildren() ||
tree.Parent() == NULL);
BOOST_REQUIRE(tree.NumChildren() <= tree.MaxNumChildren());
CheckFills(*tree.Children()[i]);
}
}
}
示例2: TreeType
bool HilbertRTreeSplit<splitOrder>::
SplitNonLeafNode(TreeType* tree, std::vector<bool>& relevels)
{
// If we are splitting the root node, we need will do things differently so
// that the constructor and other methods don't confuse the end user by giving
// an address of another node.
if (tree->Parent() == NULL)
{
// We actually want to copy this way. Pointers and everything.
TreeType* copy = new TreeType(*tree, false);
// Only the root node owns this variable.
copy->AuxiliaryInfo().HilbertValue().OwnsValueToInsert() = false;
copy->Parent() = tree;
tree->NumChildren() = 0;
tree->NullifyData();
tree->children[(tree->NumChildren())++] = copy;
SplitNonLeafNode(copy, relevels);
return true;
}
TreeType* parent = tree->Parent();
size_t iTree = 0;
for (iTree = 0; parent->children[iTree] != tree; iTree++);
// Try to find splitOrder cooperating siblings in order to redistribute
// children among them and avoid split.
size_t firstSibling, lastSibling;
if (FindCooperatingSiblings(parent, iTree, firstSibling, lastSibling))
{
RedistributeNodesEvenly(parent, firstSibling, lastSibling);
return false;
}
// We can not find splitOrder cooperating siblings since they are all full.
// We introduce new one instead.
size_t iNewSibling = (iTree + splitOrder < parent->NumChildren() ?
iTree + splitOrder : parent->NumChildren());
for (size_t i = parent->NumChildren(); i > iNewSibling ; i--)
parent->children[i] = parent->children[i - 1];
parent->NumChildren()++;
parent->children[iNewSibling] = new TreeType(parent);
lastSibling = (iTree + splitOrder < parent->NumChildren() ?
iTree + splitOrder : parent->NumChildren() - 1);
firstSibling = (lastSibling > splitOrder ?
lastSibling - splitOrder : 0);
assert(lastSibling - firstSibling <= splitOrder);
assert(firstSibling >= 0);
assert(lastSibling < parent->NumChildren());
// Redistribute children among (splitOrder + 1) cooperating siblings evenly.
RedistributeNodesEvenly(parent, firstSibling, lastSibling);
if (parent->NumChildren() == parent->MaxNumChildren() + 1)
SplitNonLeafNode(parent, relevels);
return false;
}