Пример #1
0
        /// <summary>
        /// 在自己插入自己的时候,此函数会引发一系列问题
        /// </summary>
        /// <param name="index"></param>
        /// <param name="listData"></param>
        public void InsertRange(int index, ArrayListMy listData)
        {
            while (_count + listData._count > _arrayListData.Length)
            {
                object[] temp = new object[_arrayListData.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    temp[i] = _arrayListData[i];
                }

                _arrayListData = new object[_arrayListData.Length * 2];
                //_capacity = _arrayListData.Length;
                for (int i = 0; i < temp.Length; i++)
                {
                    _arrayListData[i] = temp[i];
                }
            }

            for (int i = _count - 1; i > index - 1; i--)
            {
                _arrayListData[i + listData.Count] = _arrayListData[i];
            }

            _count += listData.Count;

            for (int i = 0; i < listData.Count; i++)
            {
                _arrayListData[index + i] = listData._arrayListData[i];
            }
        }
Пример #2
0
        public ArrayListMy GetRange(int startIndex, int count)
        {
            ArrayListMy temp = new ArrayListMy();

            for (int i = startIndex; i < startIndex + count; i++)
            {
                temp.Add(_arrayListData[i]);
            }
            return(temp);
        }
Пример #3
0
        public void AddRange(ArrayListMy listData)
        {
            while (_count + listData._count > _arrayListData.Length)
            {
                object[] temp = new object[_arrayListData.Length];
                for (int i = 0; i < temp.Length; i++)
                {
                    temp[i] = _arrayListData[i];
                }

                _arrayListData = new object[_arrayListData.Length * 2];
                //_capacity = _arrayListData.Length;
                for (int i = 0; i < temp.Length; i++)
                {
                    _arrayListData[i] = temp[i];
                }
            }

            for (int i = 0; i < listData._count; i++)
            {
                _arrayListData[_count + i] = listData._arrayListData[i];
            }
            _count += listData.Count;
        }