private void BuildTree(string s) { if (Regex.IsMatch(s, "^([0-9]+,)*[0-9]+$")) { tree = BuildIntTree(); } else if (Regex.IsMatch(s, "^([A-Za-z]+,)*[A-Za-z]+$")) { tree = BuildStringTree(); } else { MessageBox.Show("Некорректный формат списка узлов дерева."); return; } textBoxPreOrder.Text = tree.PreOrderTraverse(); textBoxInOrder.Text = tree.InOrderTraverse(); textBoxPostOrder.Text = tree.PostOrderTraverse(); tree.ComputeNodePositions(); textBoxThreadedInOrder.Text = tree.MakeInOrderRightThreaded() .ThreadedTraverse(); }
private BinaryTree BuildIntTree() { tree = new BinaryTree<int>(); foreach (var item in textBox1.Text.Split(',')) { ((BinaryTree<int>)tree).Insert(Convert.ToInt32(item)); } return tree; }
private BinaryTree BuildStringTree() { tree = new BinaryTree<string>(); foreach (var item in textBox1.Text.Split(',')) { ((BinaryTree<string>)tree).Insert(item); } return tree; }
private void button2_Click(object sender, EventArgs e) { tree = null; BuildTree(textBox1.Text); panel1.Invalidate(); }
private void textBox1_TextChanged(object sender, EventArgs e) { tree = null; panel1.Invalidate(); textBoxPreOrder.Clear(); textBoxInOrder.Clear(); textBoxPostOrder.Clear(); textBoxThreadedInOrder.Clear(); }
private void BuildSample(string s) { textBox1.Text = s; tree = null; panel1.Invalidate(); textBoxPreOrder.Clear(); textBoxInOrder.Clear(); textBoxPostOrder.Clear(); textBoxThreadedInOrder.Clear(); BuildTree(s); }