public static void SBT_Test8() { SBTnodeI sbt1 = new SBTnodeI(1); SBTnodeI sbt2 = new SBTnodeI(2); SBTnodeI sbt3 = new SBTnodeI(3); SBTnodeI sbt4 = new SBTnodeI(4); sbt1.ChangeLeftSubtree(sbt2); sbt1.ChangeRightSubtree(sbt3); Console.WriteLine("{0}, {1}", sbt1.Left.Data, sbt1.Right.Data); sbt1.ChangeLeftSubtree(null); Console.WriteLine(sbt1.IsLeftEmpty()); sbt1.ChangeLeftSubtree(sbt4); sbt3.ChangeRightSubtree(sbt2); Console.WriteLine(sbt1.Height); Console.WriteLine(sbt3.Height); Console.WriteLine(sbt2.Height); Console.WriteLine(sbt1.GetHeightDiff()); /* * result : * 2, 3 * True * 2 * 1 * 0 * -1 */ }
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; 기대한대로 캐스팅오류 제대로 발생해주시구연~~~~~~ }
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); } }