static void Main(string[] args)
        {
            IntSet A = new IntSet(33);
            IntSet B = new IntSet(33);

            A.Insert(5);
            A.Insert(30);
            A.Insert(23);

            B.Insert(5);
            B.Insert(24);
            B.Insert(9);
            Console.WriteLine("A集合:{0};{1}", A.GetBitString(), A.GetElements());
            Console.WriteLine("B集合:{0};{1}", B.GetBitString(), B.GetElements());

            IntSet C;
            C = A.Union(B);
            Console.WriteLine("A并B :{0}:{1}", C.GetBitString(), C.GetElements());
            C = A.Intersect(B);
            Console.WriteLine("A交B :{0}:{1}", C.GetBitString(), C.GetElements());
            C = A.DiffSet(B);
            Console.WriteLine("A差B :{0}:{1}", C.GetBitString(), C.GetElements());
            C = A.Complement();
            Console.WriteLine("A的补:{0}:{1}", C.GetBitString(), C.GetElements());
        }
Esempio n. 2
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);
        }
        public void complement_returns_correct_result(IntSet set)
        {
            var got = set.Complement();

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

            int countToCheck = 1000;

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

            set_is_optimized(got);
        }
Esempio n. 4
0
 public IntSet Complement(IntSet charClass)
 {
     return(charClass.Complement());
 }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void complement_returns_correct_result(IntSet set)
        {
            var got = set.Complement();
            foreach (var item in set)
            {
                Assert.IsTrue(!got.Contains(item));
            }

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

            set_is_optimized(got);
        }
Esempio n. 7
0
 public CharSetNode Complement()
 {
     return(new CharSetNode(Characters.Complement()));
 }
Esempio n. 8
0
 public IntSet Complement(IntSet charClass) 
 { 
     return charClass.Complement();
 }
 public override void RemoveAll(IntSet other)
 {
     var complemented = (IntervalIntSetBase)other.Complement(this);
     this.intervals = complemented.intervals;
     this.bounds = complemented.bounds;
     this.hash = complemented.hash;
 }