コード例 #1
0
        /**
         * Print the subtree rooted at node *top to the output stream
         * @param out the output stream
         * @param prefix the number of spaces ' ' in front of each node
         * @param top the current tree sub root
         */
        public string printSubTree(int prefix, SafraTreeNode top)
        {
            string returnString = "";

            for (int i = 0; i < prefix; i++)
            {
                returnString += " ";
            }
            returnString += top.ToString() + "\r\n";

            //for (SafraTreeNode::child_iterator it=top->children_begin();
            // it!=top->children_end();
            // ++it) {
            //  printSubTree(out, prefix+1, *it);
            //}

            SafraTreeNode it = top.children_begin();

            while (it != top.children_end())
            {
                printSubTree(prefix + 1, it);

                it = it.increment();
            }
            return(returnString);
        }
コード例 #2
0
ファイル: SafraTree.cs プロジェクト: nhannhan159/PAT
        /**
          * Print the subtree rooted at node *top to the output stream
          * @param out the output stream
          * @param prefix the number of spaces ' ' in front of each node
          * @param top the current tree sub root
          */
        public string printSubTree(int prefix, SafraTreeNode top)
        {
            string returnString = "";
            for (int i = 0; i < prefix; i++)
            {
                returnString += " ";
            }
            returnString += top.ToString() + "\r\n";

            //for (SafraTreeNode::child_iterator it=top->children_begin();
            // it!=top->children_end();
            // ++it) {
            //  printSubTree(out, prefix+1, *it);
            //}

            SafraTreeNode it = top.children_begin();
            while (it != top.children_end())
            {
                printSubTree(prefix + 1, it);

                it = it.increment();
            }
            return returnString;
        }