Esempio n. 1
0
        public void intersect_with_set_of_different_size(IntSet x)
        {
            var otherSetType = new BitSetType(10);
            var y = otherSetType.Of(2, 5, 9);

            var intersection = x.Intersect(y);
            var hsIntersection = new HashSet<int>(x);
            hsIntersection.IntersectWith(new HashSet<int>(y));
            CollectionAssert.AreEquivalent(hsIntersection, hsIntersection);

            set_is_optimized(intersection);
        }
Esempio n. 2
0
        public void addall_with_set_of_different_size(IntSet set)
        {
            var otherSetType = new BitSetType(10);
            var other = otherSetType.Of(2, 5, 9);

            MutableIntSet editedSet = set.EditCopy();
            editedSet.AddAll(other);
            Assert.IsTrue(editedSet.IsSupersetOf(other));
            Assert.IsTrue(set.Union(other).SetEquals(editedSet));
            IntSet result = editedSet.CompleteAndDestroy();
            Assert.IsTrue(result.IsSupersetOf(other));
            Assert.IsTrue(set.Union(other).SetEquals(result));
        }
Esempio n. 3
0
        public void complement_with_set_of_different_size_returns_correct_result(IntSet set)
        {
            var otherSetType = new BitSetType(10);
            var y = otherSetType.Of(2, 5, 9);

            var got = set.Complement(y);
            foreach (var item in set)
            {
                Assert.IsTrue(!got.Contains(item));
            }

            foreach (var item in y)
            {
                Assert.IsTrue(got.Contains(item) || set.Contains(item));
            }

            int countToCheck = 1000;
            foreach (var item in got)
            {
                Assert.IsFalse(set.Contains(item));
                if (--countToCheck == 0)
                {
                    break;
                }
            }

            set_is_optimized(got);
        }