If I construct, my own binary tree, then I can find the depth of each node. The sample code is as follows
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);
}
But wondering, since map is a b-tree, is it possible to write something similar to this for a std::map?