Ejemplo n.º 1
0
        public ArithmeticSet Difference(ArithmeticSet other)
        {
            List <IntPrimitive> list      = new List <IntPrimitive>(set);
            List <IntPrimitive> otherList = new List <IntPrimitive>(other.set);

            for (int i = 0; i < list.Count; i++)
            {
                if (otherList.Contains(list[i]))
                {
                    list.RemoveAt(i);
                    i--;
                }
            }

            return(new ArithmeticSet(list.ToArray()));
        }
Ejemplo n.º 2
0
        public ArithmeticSet Intersection(ArithmeticSet other)
        {
            List <IntPrimitive> list      = new List <IntPrimitive>(set);
            List <IntPrimitive> otherList = new List <IntPrimitive>(other.set);

            List <IntPrimitive> ret = new List <IntPrimitive>(this.Union(other).set);

            for (int i = 0; i < ret.Count; i++)
            {
                var item = ret[i];
                if (!list.Contains(item) || !otherList.Contains(item))
                {
                    ret.RemoveAt(i);
                    i--;
                }
            }

            return(new ArithmeticSet(ret.ToArray()));
        }
Ejemplo n.º 3
0
        public ArithmeticSet Union(ArithmeticSet other)
        {
            if (set.Length == 0)
            {
                return(other);
            }

            if (other.set.Length == 0)
            {
                return(this);
            }

            IntPrimitive[] newSet = new IntPrimitive[set.Length + other.set.Length];
            Array.Copy(set, 0, newSet, 0, set.Length);
            Array.Copy(other.set, 0, newSet, set.Length, other.set.Length);

            newSet = ResolveSet(newSet);

            return(new ArithmeticSet(newSet));
        }
Ejemplo n.º 4
0
 public bool IsDisjoint(ArithmeticSet other) => this.Intersection(other).set.Length == EmptySet.set.Length;