コード例 #1
0
        public void accept(ReflectiveVisitable v)
        {
            v.Visit(this);
            ++tabs;
            tab = "";
            for (int i = 0; i < tabs; i++)
            {
                tab += "   ";
            }
            AbstractNode children = Child;

            while (children != null)
            {
                Console.Write(tab);
                children.accept(v);
                children = children.mysib;
                --tabs;
            }
        }
コード例 #2
0
        public void PreOrderWalk(AbstractNode node, string prefix = "")
        {
            //string s = @"├│└─";
            if (node == null)
            {
                return;
            }

            bool isLastChild = (node.Sib == null);

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(prefix);
            Console.Write(isLastChild ? "└─ " : "├─ ");
            Console.ResetColor();
            node.accept(this);
            PreOrderWalk(node.Child, prefix + (isLastChild ? "   " : "│  "));

            if (!isLastChild)
            {
                PreOrderWalk(node.Sib, prefix);
            }
        }