public CSet Union(CSet aSet) { CSet tempSet = new CSet(); foreach (Object hashObject in data.Keys) { tempSet.Add(this.data[hashObject]); } foreach (Object hashObject in aSet.data.Keys) { if (!(this.data.ContainsKey(hashObject))) { tempSet.Add(aSet.data[hashObject]); } } return(tempSet); }
public CSet Difference(CSet aSet) { CSet tempSet = new CSet(); foreach (Object hashObject in data.Keys) { if (!(aSet.data.Contains(hashObject))) { tempSet.Add(data[hashObject]); } } return(tempSet); }
public CSet Intersection(CSet aSet) { CSet temSet = new CSet(); foreach (Object hashObject in data.Keys) { if (aSet.data.Contains(hashObject)) { temSet.Add(aSet.data[hashObject]); } } return(temSet); }
private void btnRun_Click(object sender, EventArgs e) { CSet setA = new CSet(); CSet setB = new CSet(); CSet setC = new CSet(); string a = tbA.Text.TrimEnd(); string b = tbB.Text.TrimEnd(); string[] tempA = a.Split(); string[] tempB = b.Split(); foreach (string item in tempA) { setA.Add(item); } foreach (string item in tempB) { setB.Add(item); } setC = setA.Union(setB); richTextBox1.Text += String.Format("Множеството А = {0}\n", setA.ToString()); richTextBox1.Text += String.Format("Множеството B = {0}\n", setB.ToString()); richTextBox1.Text += String.Format("{0} обединение {1} = {2}\n", setA.ToString(), setB.ToString(), setC.ToString()); setC = setA.Intersection(setB); richTextBox1.Text += String.Format("{0} сечение {1} = {2}\n", setA.ToString(), setB.ToString(), setC.ToString()); setC = setA.Difference(setB); richTextBox1.Text += String.Format("{0} разлика {1} = {2}\n", setA.ToString(), setB.ToString(), setC.ToString()); setC = setB.Difference(setA); richTextBox1.Text += String.Format("{0} разлика {1} = {2}\n", setA.ToString(), setB.ToString(), setC.ToString()); if (setB.IsSubset(setA)) { richTextBox1.Text += String.Format("{0} е подмножество на {1}\n", setB.ToString(), setA.ToString()); } else { richTextBox1.Text += String.Format("{0} не е подмножество на {1}\n", setB.ToString(), setA.ToString()); } }