Ejemplo n.º 1
0
        public static void PowerSetTest()
        {
            PowerSet <int> ps1 = new PowerSet <int>();
            PowerSet <int> ps2 = new PowerSet <int>();


            ps1.Put(1);
            ps1.Put(3);
            ps1.Put(5);

            ps2.Put(2);
            ps2.Put(3);
            ps2.Put(4);


            var ps3 = ps1.Difference(ps2);

            //Console.WriteLine(ps3);
            foreach (var item in ps3.items.Keys)
            {
                Console.WriteLine(item);
            }

            //Console.WriteLine($"Size: {ps3.Size()}");
        }
        public void Difference()
        {
            // Difference with PowerSet2 contains 2 similar items (expected 3 different items)
            testPowerSet = testPowerSet1.Difference(testPowerSet2);
            Assert.AreEqual(3, testPowerSet.capacity);
            Assert.AreEqual(true, testPowerSet.Get(8));
            Assert.AreEqual(true, testPowerSet.Get(10));
            Assert.AreEqual(true, testPowerSet.Get(12));
            Assert.AreEqual(false, testPowerSet.Get(16));

            testPowerSet = testPowerSet2.Difference(testPowerSet1);
            Assert.AreEqual(3, testPowerSet.capacity);
            Assert.AreEqual(true, testPowerSet.Get(162));
            Assert.AreEqual(true, testPowerSet.Get(0));
            Assert.AreEqual(true, testPowerSet.Get(5));
            Assert.AreEqual(false, testPowerSet.Get(12));

            // Difference with empty set (A / 0 = A)
            Assert.AreEqual(5, testPowerSet1.Difference(testPowerSet0).capacity);

            // Difference with empty set (0 / A = 0)
            Assert.AreEqual(0, testPowerSet0.Difference(testPowerSet1).capacity);
        }