예제 #1
0
        internal void DoSliceAssign(SliceAssign assign, int size, object value)
        {
            int ostart, ostop, ostep;

            indices(size, out ostart, out ostop, out ostep);
            DoSliceAssign(assign, ostart, ostop, ostep, value);
        }
예제 #2
0
        internal void DoSliceAssign(SliceAssign assign, int size, object value)
        {
            int ostart, ostop, ostep;

            indices(size, out ostart, out ostop, out ostep);

            if (this.step == null)
            {
                throw Ops.ValueError("cannot do slice assignment w/ no step");
            }

            DoSliceAssign(assign, ostart, ostop, ostep, value);
        }
예제 #3
0
        private static void OtherSliceAssign(SliceAssign assign, int start, int stop, int step, object value)
        {
            // get enumerable data into a list, and then
            // do the slice.
            IEnumerator enumerator = Ops.GetEnumerator(value);
            List        sliceData  = new List();

            while (enumerator.MoveNext())
            {
                sliceData.AddNoLock(enumerator.Current);
            }

            DoSliceAssign(assign, start, stop, step, sliceData);
        }
예제 #4
0
 private static void DoSliceAssign(SliceAssign assign, int start, int stop, int step, object?value)
 {
     // fast paths, if we know the size then we can
     // do this quickly.
     if (value is IList list)
     {
         int count = PythonOps.GetSliceCount(start, stop, step);
         ListSliceAssign(assign, start, count, step, list);
     }
     else
     {
         OtherSliceAssign(assign, start, stop, step, value);
     }
 }
예제 #5
0
        private static void SequenceSliceAssign(SliceAssign assign, int start, int n, int step, ISequence lst)
        {
            if (lst.GetLength() < n)
            {
                throw Ops.ValueError("too few items in the enumerator. need {0}", n);
            }
            else if (lst.GetLength() != n)
            {
                throw Ops.ValueError("too many items in the enumerator need {0}", n);
            }

            for (int i = 0, index = start; i < n; i++, index += step)
            {
                assign(index, lst[i]);
            }
        }
예제 #6
0
        private static void ListSliceAssign(SliceAssign assign, int start, int n, int step, IList lst)
        {
            if (lst.Count < n)
            {
                throw Ops.ValueError("too few items in the enumerator. need {0} have {1}", n, lst.Count);
            }
            else if (lst.Count != n)
            {
                throw Ops.ValueError("too many items in the enumerator need {0} have {1}", n, lst.Count);
            }

            for (int i = 0, index = start; i < n; i++, index += step)
            {
                assign(index, lst[i]);
            }
        }
예제 #7
0
        private static void DoSliceAssign(SliceAssign assign, int start, int stop, int step, object value)
        {
            stop = step > 0 ? Math.Max(stop, start) : Math.Min(stop, start);
            int n = Math.Max(0, (step > 0 ? (stop - start + step - 1) : (stop - start + step + 1)) / step);

            // fast paths, if we know the size then we can
            // do this quickly.
            if (value is IList)
            {
                ListSliceAssign(assign, start, n, step, value as IList);
            }
            else
            {
                OtherSliceAssign(assign, start, stop, step, value);
            }
        }
예제 #8
0
        private static void DoSliceAssign(SliceAssign assign, int start, int stop, int step, object value)
        {
            int n = (step > 0 ? (stop - start + step - 1) : (stop - start + step + 1)) / step;

            // fast paths, if we know the size then we can
            // do this quickly.
            if (value is IList)
            {
                ListSliceAssign(assign, start, n, step, value as IList);
            }
            else if (value is ISequence)
            {
                SequenceSliceAssign(assign, start, n, step, value as ISequence);
            }
            else
            {
                OtherSliceAssign(assign, start, stop, step, value);
            }
        }
예제 #9
0
파일: Slice.cs 프로젝트: jxnmaomao/ironruby
        private static void OtherSliceAssign(SliceAssign assign, int start, int stop, int step, object value) {
            // get enumerable data into a list, and then
            // do the slice.
            IEnumerator enumerator = PythonOps.GetEnumerator(value);
            List sliceData = new List();
            while (enumerator.MoveNext()) sliceData.AddNoLock(enumerator.Current);

            DoSliceAssign(assign, start, stop, step, sliceData);
        }
예제 #10
0
파일: Slice.cs 프로젝트: jxnmaomao/ironruby
        private static void ListSliceAssign(SliceAssign assign, int start, int n, int step, IList lst) {
            if (lst.Count < n) throw PythonOps.ValueError("too few items in the enumerator. need {0} have {1}", n, lst.Count);
            else if (lst.Count != n) throw PythonOps.ValueError("too many items in the enumerator need {0} have {1}", n, lst.Count);

            for (int i = 0, index = start; i < n; i++, index += step) {
                assign(index, lst[i]);
            }
        }
예제 #11
0
파일: Slice.cs 프로젝트: jxnmaomao/ironruby
 private static void DoSliceAssign(SliceAssign assign, int start, int stop, int step, object value) {
     stop = step > 0 ? Math.Max(stop, start) : Math.Min(stop, start);
     int n = Math.Max(0, (step > 0 ? (stop - start + step - 1) : (stop - start + step + 1)) / step);
     // fast paths, if we know the size then we can
     // do this quickly.
     if (value is IList) {
         ListSliceAssign(assign, start, n, step, value as IList);
     } else {
         OtherSliceAssign(assign, start, stop, step, value);
     }
 }
예제 #12
0
파일: Slice.cs 프로젝트: jxnmaomao/ironruby
        internal void DoSliceAssign(SliceAssign assign, int size, object value) {
            int ostart, ostop, ostep;
            indices(size, out ostart, out ostop, out ostep);

            if (this._step == null) throw PythonOps.ValueError("cannot do slice assignment w/ no step");

            DoSliceAssign(assign, ostart, ostop, ostep, value);
        }
예제 #13
0
파일: Slice.cs 프로젝트: jcteague/ironruby
        private static void SequenceSliceAssign(SliceAssign assign, int start, int n, int step, ISequence lst) {
            if (lst.__len__() < n) throw PythonOps.ValueError("too few items in the enumerator. need {0}", n);
            else if (lst.__len__() != n) throw PythonOps.ValueError("too many items in the enumerator need {0}", n);

            for (int i = 0, index = start; i < n; i++, index += step) {
                assign(index, lst[i]);
            }

        }
예제 #14
0
 internal static void DoSliceAssign(SliceAssign assign, int start, int stop, int step, object value)
 {
     int n = (step > 0 ? (stop - start + step - 1) : (stop - start + step + 1)) / step;
     // fast paths, if we know the size then we can
     // do this quickly.
     if (value is IList) {
         ListSliceAssign(assign, start, n, step, value as IList);
     } else if (value is ISequence) {
         SequenceSliceAssign(assign, start, n, step, value as ISequence);
     } else {
         OtherSliceAssign(assign, start, stop, step, value);
     }
 }
예제 #15
0
 internal void DoSliceAssign(SliceAssign assign, int size, object value) {
     int ostart, ostop, ostep;
     indices(size, out ostart, out ostop, out ostep);
     DoSliceAssign(assign, ostart, ostop, ostep, value);
 }