示例#1
0
        /// <summary>
        /// Return a string which is the concatenation of the strings
        /// in the sequence seq. The separator between elements is the
        /// string providing this method
        /// </summary>
        public ByteArray /*!*/ join(object /*!*/ sequence)
        {
            IEnumerator seq = PythonOps.GetEnumerator(sequence);

            if (!seq.MoveNext())
            {
                return(new ByteArray());
            }

            // check if we have just a sequnce of just one value - if so just
            // return that value.
            object curVal = seq.Current;

            if (!seq.MoveNext())
            {
                return(JoinOne(curVal));
            }

            List <byte> ret = new List <byte>();

            ByteOps.AppendJoin(curVal, 0, ret);

            int index = 1;

            do
            {
                ret.AddRange(this);

                ByteOps.AppendJoin(seq.Current, index, ret);

                index++;
            } while (seq.MoveNext());

            return(new ByteArray(ret));
        }
示例#2
0
文件: Bytes.cs 项目: SueDou/python
        public Bytes join([NotNull] List /*!*/ sequence)
        {
            if (sequence.__len__() == 0)
            {
                return(new Bytes());
            }
            else if (sequence.__len__() == 1)
            {
                return(JoinOne(sequence[0]));
            }

            List <byte> ret = new List <byte>();

            ByteOps.AppendJoin(sequence._data[0], 0, ret);
            for (int i = 1; i < sequence._size; i++)
            {
                ret.AddRange(this);
                ByteOps.AppendJoin(sequence._data[i], i, ret);
            }

            return(new Bytes(ret));
        }