示例#1
0
文件: Set.cs 项目: rudimk/dlr-dotnet
        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);
        }
示例#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)));
        }
示例#3
0
文件: Set.cs 项目: rudimk/dlr-dotnet
        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);
        }
示例#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);
        }
示例#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)));
        }
示例#6
0
文件: Set.cs 项目: rudimk/dlr-dotnet
        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);
        }
示例#7
0
文件: Set.cs 项目: rudimk/dlr-dotnet
        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);
        }
示例#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)));
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#13
0
文件: Set.cs 项目: rudimk/dlr-dotnet
        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);
        }
示例#14
0
文件: Set.cs 项目: rudimk/dlr-dotnet
 public ISet difference()
 {
     return(SetHelpers.MakeSet(this, this));
 }
示例#15
0
文件: Set.cs 项目: rudimk/dlr-dotnet
 public ISet intersection()
 {
     return(SetHelpers.MakeSet(this, this));
 }
示例#16
0
文件: Set.cs 项目: rudimk/dlr-dotnet
 public ISet union()
 {
     return(SetHelpers.MakeSet(this, this));
 }