Example #1
0
        public static ISet Union(ISet x, object y)
        {
            ISet        set = SetHelpers.MakeSet(x, x);
            IEnumerator ie  = PythonOps.GetEnumerator(y);

            while (ie.MoveNext())
            {
                set.PrivAdd(ie.Current);
            }
            return(set);
        }
Example #2
0
        public ISet __rsub__(ISet s)
        {
            SetCollection set = s as SetCollection;

            if (set != null)
            {
                return(set.Difference(this));
            }

            return(SetHelpers.MakeSet(this, s.PrivDifference(this)));
        }
Example #3
0
        public FrozenSetCollection copy()
        {
            // Python behavior: If we're a non-derived frozen set, we return ourselves.
            // If we're a derived frozen set we make a new set of our type that contains our
            // contents.
            if (this.GetType() == typeof(FrozenSetCollection))
            {
                return(this);
            }
            FrozenSetCollection set = (FrozenSetCollection)SetHelpers.MakeSet(this, this);

            return(set);
        }
Example #4
0
        public ISet OperatorReverseSubtract(ISet s)
        {
            FrozenSetCollection fs = s as FrozenSetCollection;

            if (fs != null)
            {
                return(fs.Difference(this));
            }

            ISet set = SetHelpers.MakeSet(this, s.PrivDifference(this));

            set.PrivFreeze();
            return(set);
        }
Example #5
0
        public ISet __rxor__(ISet s)
        {
            if (s.GetLength() < GetLength())
            {
                return(SymmetricDifference(s));
            }
            SetCollection set = s as SetCollection;

            if (set != null)
            {
                return(set.SymmetricDifference(this));
            }

            return(SetHelpers.MakeSet(this, s.PrivSymmetricDifference(this)));
        }
Example #6
0
        public static ISet Difference(ISet x, object y)
        {
            ISet res = SetHelpers.MakeSet(x, x);

            IEnumerator ie = PythonOps.GetEnumerator(y);

            while (ie.MoveNext())
            {
                if (res.__contains__(ie.Current))
                {
                    res.PrivRemove(ie.Current);
                }
            }
            return(res);
        }
Example #7
0
        public static ISet Intersection(ISet x, object y)
        {
            ISet res = SetHelpers.MakeSet(x);

            IEnumerator ie = PythonOps.GetEnumerator(y);

            while (ie.MoveNext())
            {
                if (x.__contains__(ie.Current))
                {
                    res.PrivAdd(ie.Current);
                }
            }
            return(res);
        }
Example #8
0
        public ISet __ror__(ISet s)
        {
            if (s.GetLength() < GetLength())
            {
                return(Union(s));
            }

            SetCollection set = s as SetCollection;

            if (set != null)
            {
                return(set.Union(this));
            }

            return(SetHelpers.MakeSet(this, s.PrivUnion(this)));
        }
Example #9
0
        public static ISet Intersection(ISet x, object y)
        {
            ISet res = SetHelpers.MakeSet(x);

            IEnumerator ie = Ops.GetEnumerator(y);

            while (ie.MoveNext())
            {
                if (x.Contains(ie.Current) == Ops.TRUE)
                {
                    res.PrivAdd(ie.Current);
                }
            }
            res.PrivFreeze();
            return(res);
        }
Example #10
0
        public ISet OperatorReverseXor(ISet s)
        {
            if (s.GetLength() < GetLength())
            {
                return(SymmetricDifference(s));
            }
            FrozenSetCollection fs = s as FrozenSetCollection;

            if (fs != null)
            {
                return(fs.SymmetricDifference(this));
            }
            ISet set = SetHelpers.MakeSet(this, s.PrivSymmetricDifference(this));

            set.PrivFreeze();
            return(set);
        }
Example #11
0
        public object OperatorReverseOr(ISet s)
        {
            if (s.GetLength() < GetLength())
            {
                return(Union(s));
            }
            FrozenSetCollection fs = s as FrozenSetCollection;

            if (fs != null)
            {
                return(fs.Union(this));
            }
            ISet set = SetHelpers.MakeSet(this, s.PrivUnion(this));

            set.PrivFreeze();
            return(set);
        }
Example #12
0
        public static ISet Difference(ISet x, object y)
        {
            ISet res = SetHelpers.MakeSet(x, x) as ISet;

            Debug.Assert(res != null);

            IEnumerator ie = Ops.GetEnumerator(y);

            while (ie.MoveNext())
            {
                if (res.Contains(ie.Current) == Ops.TRUE)
                {
                    res.PrivRemove(ie.Current);
                }
            }
            res.PrivFreeze();
            return(res);
        }
Example #13
0
        public static ISet SymmetricDifference(ISet x, object y)
        {
            SetCollection otherSet = new SetCollection(PythonOps.GetEnumerator(y));       //make a set to deal w/ dups in the enumerator
            ISet          res      = SetHelpers.MakeSet(x, x) as ISet;

            Debug.Assert(res != null);

            foreach (object o in otherSet)
            {
                if (res.__contains__(o))
                {
                    res.PrivRemove(o);
                }
                else
                {
                    res.PrivAdd(o);
                }
            }
            return(res);
        }
Example #14
0
 public ISet difference()
 {
     return(SetHelpers.MakeSet(this, this));
 }
Example #15
0
 public ISet intersection()
 {
     return(SetHelpers.MakeSet(this, this));
 }
Example #16
0
 public ISet union()
 {
     return(SetHelpers.MakeSet(this, this));
 }