本文整理汇总了C++中InternalNode::ChildAt方法的典型用法代码示例。如果您正苦于以下问题:C++ InternalNode::ChildAt方法的具体用法?C++ InternalNode::ChildAt怎么用?C++ InternalNode::ChildAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternalNode
的用法示例。
在下文中一共展示了InternalNode::ChildAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: level
/*! \brief Goes into a given direction.
\a direction can be
- \c FORWARD: Forward/to the right. Goes to the next child node of the
current node.
- \c BACKWARDS: Forward/to the right. Goes to the previous child node of
the current node.
- \c UP: Up one level (in root direction). Goes to the parent node of
the current node. The current node is the child node, it is pointed
to afterward.
- \c DOWN: Down one level (in leaf direction). Goes to the child node of
the current node the iterator currently points at. Points afterwards to
the 0th child node of the new current node (unless it is a leaf node).
\c FORWARD and \c BACKWARDS do not change the current node!
\param direction \c FORWARD, \c BACKWARDS, \c UP or \c DOWN
\return \c B_OK, if everything went fine
*/
status_t
TreeIterator::GoTo(uint32 direction)
{
status_t error = InitCheck();
if (error == B_OK) {
switch (direction) {
case FORWARD:
{
if (fCurrentNode->IsInternal()
&& fIndex < fCurrentNode->CountItems()) {
fIndex++;
} else {
error = B_ENTRY_NOT_FOUND;
}
break;
}
case BACKWARDS:
{
if (fCurrentNode->IsInternal() && fIndex > 0)
fIndex--;
else
error = B_ENTRY_NOT_FOUND;
break;
}
case UP:
{
error = _PopTopNode();
break;
}
case DOWN:
{
if (fCurrentNode->IsInternal()) {
InternalNode *internal = fCurrentNode->ToInternalNode();
const DiskChild *child = internal->ChildAt(fIndex);
if (child) {
Node *node = NULL;
error = fTree->GetNode(child->GetBlockNumber(), &node);
if (error == B_OK)
error = _PushCurrentNode(node, 0);
} else
error = B_ENTRY_NOT_FOUND;
} else
error = B_ENTRY_NOT_FOUND;
break;
}
}
}
return error;
}