Beispiel #1
0
        public static void SBT_Test1()
        {
            SBTnodeI A = new SBTnodeI(typeof(int), 10);

            //Console.WriteLine(A.Left);
            Console.WriteLine(A.Data);
            Console.WriteLine(A.DataType);
            Console.WriteLine(A.Data.GetType());
            A.Data = 30;
            Console.WriteLine(A.Data);
            //A.Data = 30.5;
            //Console.WriteLine(A.Data); 캐스팅오류 제대로 발생해주시구연~~~~~~~
            Console.WriteLine("{0}, {1}, {2}", A.IsLeftEmpty(), A.IsRightEmpty(), A.IsTerminal());
            A.Left = new SBTnodeI(typeof(double), 20.5);
            Console.WriteLine("{0}, {1}, {2}", A.IsLeftEmpty(), A.IsRightEmpty(), A.IsTerminal());
            A.Right = new SBTnodeI(typeof(string), "퍄퍄");
            Console.WriteLine("{0}, {1}, {2}", A.IsLeftEmpty(), A.IsRightEmpty(), A.IsTerminal());
            Console.WriteLine(A.Left.Data.GetType());
            Console.WriteLine(A.Right.Data.GetType());
            //A.Right.Data = 20; 기대한대로 캐스팅오류 제대로 발생해주시구연~~~~~~
        }
Beispiel #2
0
        public static void buildtv(List <TV_Block> tv, SBTnodeI nd, int depth, int rel, ref int cont_depth, ref int cont_rel)//rel = right edge length.
        {
            if (cont_depth > depth)
            {
                tv.Add(new TV_Block(String.Format("({0})", nd.Data.ToString()), depth, ++cont_rel));
            }
            else
            {
                tv.Add(new TV_Block(String.Format("({0})", nd.Data.ToString()), depth, rel));
                cont_rel = rel;
            }
            cont_depth = depth;

            if (!(nd.IsLeftEmpty()))
            {
                buildtv(tv, nd.Left, depth + 1, cont_rel, ref cont_depth, ref cont_rel);
            }

            if (!(nd.IsRightEmpty()))
            {
                buildtv(tv, nd.Right, depth + 1, cont_rel + 1, ref cont_depth, ref cont_rel);
            }
        }