Beispiel #1
0
        /// <summary>
        /// 数组子串
        /// </summary>
        /// <param name="array"></param>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        public SubArray(valueType[] array, int startIndex, int length)
        {
            FormatRange range = new FormatRange(array.length(), startIndex, length);

            Array  = array;
            Start  = range.SkipCount;
            Length = range.GetCount;
        }
Beispiel #2
0
        /// <summary>
        /// 字符子串
        /// </summary>
        /// <param name="value">字符串</param>
        /// <param name="startIndex">起始位置</param>
        /// <param name="length">长度</param>
        public SubString(string value, int startIndex, int length)
        {
            FormatRange range = new FormatRange(value.Length, startIndex, length);

            if (range.GetCount != length)
            {
                throw new IndexOutOfRangeException();
            }
            String = value;
            Start  = range.SkipCount;
            Length = length;
        }
Beispiel #3
0
        /// <summary>
        /// 添加数据集合
        /// </summary>
        /// <param name="values">数据集合</param>
        /// <param name="index">起始位置</param>
        /// <param name="count">数量</param>
        public override void Add(valueType[] values, int index, int count)
        {
            FormatRange range = new FormatRange(values.length(), index, count);

            if ((count = range.GetCount) != 0)
            {
                int newLength = Length + count;
                addToLength(newLength);
                System.Array.Copy(values, range.SkipCount, Array, Length, count);
                Length = newLength;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获取子串
        /// </summary>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public SubArray <valueType> GetSub(int startIndex, int length)
        {
            FormatRange range = new FormatRange(Length, startIndex, length);

            if (range.GetCount != length)
            {
                throw new IndexOutOfRangeException("startIndex[" + startIndex.toString() + "] + length[" + length.toString() + "] > Length[" + Length.toString() + "]");
            }
            SubArray <valueType> value = default(SubArray <valueType>);

            value.Set(Array, Start + startIndex, length);
            return(value);
        }