コード例 #1
0
ファイル: TreeNode.hpp プロジェクト: Zylann/Grid
        // Prints the node's sub-tree in a stream, using indentation
        // to represent parents and children.
        // d < 0 : display at real depth
        // d = 0 : display as root node
        // d > 0 : display at specified depth
        virtual void printTree(std::ostream & os, int d = -1) const
        {
            if(d < 0)
                d = getDepth();

            // Indentation
            for(int i = 0; i < d; i++)
                std::cout << " ";

            // Printing the node
            print(os);

            // Printing children
            typename std::map<Id_T, Val_T*>::iterator it;
            for(it = m_children.begin(); it != m_children.end(); it++)
            {
                it->second->printTree(os, d + 1);
            }
        }
コード例 #2
0
ファイル: TreeNode.hpp プロジェクト: Zylann/Grid
 // Destroys the tree node and its children.
 virtual ~TreeNode()
 {
     typename std::map<Id_T, Val_T*>::iterator it;
     for(it = m_children.begin(); it != m_children.end(); it++)
         delete it->second;
 }