【发布时间】:2018-10-12 02:31:44
【问题描述】:
如果我构建自己的二叉树,那么我可以找到每个节点的深度。 示例代码如下
template<class datatype>
void binary_node<datatype>::printNodeWithDepth(int currentNodeDepth)
{
if ( left )
left->printNodeWithDepth(currentNodeDepth+1);
std::cout << value << " and the depth is " << currentNodeDepth << std::endl;
if ( right)
right->printNodeWithDepth(currentNodeDepth+1);
}
但想知道,既然 map 是一个 b-tree,是否可以为 std::map 写类似的东西?
【问题讨论】:
-
不要将二叉树与 B 树混淆。 en.wikipedia.org/wiki/B-tree
标签: c++ dictionary std stdmap c++-standard-library