コード例 #1
0
        public void Print()
        {
            if (!ReferenceEquals(LeftNode, null))
            {
                Console.WriteLine(string.Format("{0} -> {1}", Value, LeftNode.Value));
            }
            if (!ReferenceEquals(RightNode, null))
            {
                Console.WriteLine(string.Format("{0} -> {1}", Value, RightNode.Value));
            }

            if (!ReferenceEquals(LeftNode, null))
            {
                LeftNode.Print();
            }
            if (!ReferenceEquals(RightNode, null))
            {
                RightNode.Print();
            }
        }
コード例 #2
0
        public void Print(string indent, NodePosition nodePosition, bool end_level, bool empty)
        {
            Console.Write(indent);
            if (end_level)
            {
                Console.Write("\u2514\u2500");
                indent += "  ";
            }
            else
            {
                Console.Write("\u251C\u2500");
                indent += "\u2502 ";
            }

            var stringValue = empty ? "-" : Value.ToString();

            PrintValue(stringValue, nodePosition);

            if (!empty && (LeftNode != null || RightNode != null))
            {
                if (LeftNode != null)
                {
                    LeftNode.Print(indent, NodePosition.left, false, false);
                }
                else
                {
                    Print(indent, NodePosition.left, false, true);
                }

                if (RightNode != null)
                {
                    RightNode.Print(indent, NodePosition.right, true, false);
                }
                else
                {
                    Print(indent, NodePosition.right, true, true);
                }
            }
        }