Пример #1
0
        public Set Intersection(Set c2)
        {
            Set c = new Set();
            for (int i = 0; i < this.NumberofElements(); i++)
                if (c2.Contains(this.Element(i + 1)))
                    c.Add(this.Element(i + 1));

            return (c);
        }
Пример #2
0
 public void TestInterseccion()
 {
     var conjuntoA = new Set();
     conjuntoA.Add(7);
     conjuntoA.Add(2);
     conjuntoA.Add(1);
     var conjuntoB = new Set();
     conjuntoB.Add(3);
     conjuntoB.Add(7);
     conjuntoB.Add(9);
     var conjuntoC = conjuntoA^conjuntoB;
     Assert.AreEqual(true, conjuntoC.Contains(7) );
 }
Пример #3
0
 public void TestMenos()
 {
     Set A = new Set();
     A.Add(3);
     A.Add(2);
     A.Add(1);
     Set B = new Set();
     B.Add(3);
     B.Add(7);
     B.Add(9);
     Set C = A-B;
     Assert.AreEqual(true, C.Contains(2));
     Assert.AreEqual(true, C.Contains(1) );
 }
Пример #4
0
 public void TestLargo()
 {
     Set A = new Set();
     A.Add(1);
     A.Add(5);
     A.Add(2);
     A.Add(7);
     Set B = new Set();
     B.Add(9);
     B.Add(2);
     B.Add(1);
     B.Add(8);
     B.Add(7);
     Assert.AreEqual(4, A.NumberofElements());
     Assert.AreEqual(5, B.NumberofElements());
 }
Пример #5
0
 public void TestUnion()
 {
     var conjuntoA = new Set();
     conjuntoA.Add(3);
     conjuntoA.Add(2);
     conjuntoA.Add(1);
     var conjuntoB = new Set();
     conjuntoB.Add(3);
     conjuntoB.Add(7);
     conjuntoB.Add(9);
     var conjuntoC = conjuntoA+conjuntoB;
     Assert.AreEqual(true, conjuntoC.Contains(3) );
     Assert.AreEqual(true, conjuntoC.Contains(2));
     Assert.AreEqual(true, conjuntoC.Contains(1));
     Assert.AreEqual(true, conjuntoC.Contains(7));
     Assert.AreEqual(true, conjuntoC.Contains(9));
 }
Пример #6
0
        public Set Union(Set c2)
        {
            Set c = new Set();
            for (int i = 0; i < this.NumberofElements(); i++)
                c.Add(this.Element(i + 1));
            for (int i = 0; i < c2.NumberofElements(); i++)
                if (!c.Contains(c2.Element(i + 1)))
                    c.Add(c2.Element(i + 1));

            return (c);
        }
Пример #7
0
        public Set Substract(Set c2)
        {
            Set c3 = new Set(); Set c = new Set();
            c3 = this.Intersection(c2);
            for (int i = 0; i < this.NumberofElements(); i++)
                if (c3.Contains(this.Element(i + 1)) == false)
                    c.Add(this.Element(i + 1));

            return (c);
        }