public void Interesection()
        {
            var mo = new InversionListCodePointSet('m', 'o');
            var ao = new InversionListCodePointSet('a', 'o');
            var mx = new InversionListCodePointSet('m', 'z');

            Assert.AreEqual(mo, ao.Intersect(mx));
        }
示例#2
0
        /**
         * The effect of this method is to ensure that all characters in the
         * set are not in the same equivalece class with any characters not
         * in the set.
         */
        public void MakeClasses(InversionListCodePointSet set)
        {
            var oldCount = Count;

            for (var i = 0; i < oldCount; i++)
            {
                if (classes[i].Equals(set))
                {
                    return;                     // A class for exactly this set already exists
                }
                var intersection           = classes[i].Intersect(set);
                var intersectionComplement = intersection.Complement();                 // used for difference later

                if (intersection.IsEmpty())
                {
                    continue;
                }

                if (intersection.Equals(classes[i]))                // i.e. classes[i] is subset of set
                {
                    set = set.Intersect(intersectionComplement);    // set -= intersection
                    continue;
                }

                if (intersection.Equals(set))                                  // i.e. set is subset of classes[i]
                {
                    classes[i] = classes[i].Intersect(intersectionComplement); // classes[i] -= intersection
                    classes.Add(intersection);
                    return;
                }

                set        = set.Intersect(intersectionComplement);          // set -= intersection
                classes[i] = classes[i].Intersect(intersectionComplement);   // classes[i] -= intersection
                classes.Add(intersection);
            }
        }