private void Merge_Click(object sender, EventArgs e) { List <float> lst1 = new List <float>(); //the program list List <float> lst2 = new List <float>(); //to be filled from the file lst1 = floatList.ToList(); StreamReader reader = null; OpenFileDialog open = new OpenFileDialog(); open.Title = "Open Text File"; open.Filter = "TXT files|*.txt"; open.InitialDirectory = @"C:\"; if (open.ShowDialog() == DialogResult.OK) { using (reader = new StreamReader(open.FileName)) { opendFromFile = true; OpendFilePath = open.FileName; this.Invalidate(); this.Refresh(); floatBST = new BST <float>(this); floatList = new List <float>(); string line; while ((line = reader.ReadLine()) != null) { lst2.Add(float.Parse(line)); } reader.Close(); } } while (true) { if (lst1.Count == 0 && lst2.Count == 0) { break; } if (lst1.Count != 0) { if (!floatBST.contain(lst1[0], false)) { floatBST.append(lst1[0], true); floatList.Add(lst1[0]); lst1.Remove(lst1[0]); } else { lst1.Remove(lst1[0]); } } if (lst2.Count != 0) { if (!floatBST.contain(lst2[0], false)) { floatBST.append(lst2[0], true); floatList.Add(lst2[0]); lst2.Remove(lst2[0]); } else { lst2.Remove(lst2[0]); } } } }
public StringBST() { InitializeComponent(); stringBST = new BST <string>(this); stringList = new List <string>(); }
public FloatBST() { InitializeComponent(); floatBST = new BST <float>(this); floatList = new List <float>(); }
public IntBST() { InitializeComponent(); intBST = new BST <int>(this); intList = new List <int>(); }