コード例 #1
0
ファイル: Dict.cs プロジェクト: weimingtom/IronPythonMod
        public static object FromKeys(PythonType cls, object seq, object value)
        {
            XRange xr = seq as XRange;

            if (xr != null)
            {
                int    n   = xr.GetLength();
                object ret = MakeDict(cls);
                if (ret.GetType() == typeof(Dict))
                {
                    Dict dr = ret as Dict;
                    for (int i = 0; i < n; i++)
                    {
                        dr[xr[i]] = value;
                    }
                }
                else
                {
                    // slow path, user defined dict
                    for (int i = 0; i < n; i++)
                    {
                        Ops.SetIndex(ret, xr[i], value);
                    }
                }
                return(ret);
            }
            return(fromkeysAny(cls, seq, value));
        }
コード例 #2
0
        public static object fromkeys(CodeContext context, PythonType cls, object seq, object value)
        {
            XRange xr = seq as XRange;

            if (xr != null)
            {
                int    n   = xr.__len__();
                object ret = PythonContext.GetContext(context).CallSplat(cls);
                if (ret.GetType() == typeof(PythonDictionary))
                {
                    PythonDictionary dr = ret as PythonDictionary;
                    for (int i = 0; i < n; i++)
                    {
                        dr[xr[i]] = value;
                    }
                }
                else
                {
                    // slow path, user defined dict
                    PythonContext pc = PythonContext.GetContext(context);
                    for (int i = 0; i < n; i++)
                    {
                        pc.SetIndex(ret, xr[i], value);
                    }
                }
                return(ret);
            }
            return(fromkeysAny(context, cls, seq, value));
        }
コード例 #3
0
ファイル: XRange.cs プロジェクト: weimingtom/IronPythonMod
 public XRangeIterator(XRange l)
 {
     this.l        = l;
     this.value    = l.start - l.step; // this could cause overflow, fine
     this.position = 0;
 }
コード例 #4
0
ファイル: XRange.cs プロジェクト: wangpei421/ironpython2
 public XRangeIterator(XRange xrange)
 {
     _xrange = xrange;
     _value  = xrange.Start - xrange.Step; // this could cause overflow, fine
 }
コード例 #5
0
ファイル: XRange.cs プロジェクト: FabioNascimento/DICommander
 public XRangeIterator(XRange l)
 {
     this.l = l;
     this.value = l.start - l.step; // this could cause overflow, fine
     this.position = 0;
 }