Ejemplo n.º 1
0
        public void InsertRange(int index, IEnumerable <T> collection)
        {
            if (index < 0 || index > Count)
            {
                throw new ArgumentOutOfRangeException();
            }

            ListPatch <T> list  = collection as ListPatch <T>;
            int           count = list != null ? list.Count : collection.Count();

            if (count == 0)
            {
                return;
            }

            EnsureCapacity(Count + count);
            System.Array.Copy(Array, index, Array, index + count, Count - index);

            if (list != null)
            {
                System.Array.Copy(list.Array, 0, Array, index, count);
            }
            else
            {
                foreach (var x in collection)
                {
                    Array[index++] = x;
                }
            }

            Count += count;
            Version++;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Splits the list into two parts, where the right part contains count elements.
        /// </summary>
        /// <param name="count"></param>
        /// <returns>the right part of the list</returns>
        public ListPatch <T> Split(int count)
        {
            ListPatch <T> list = new ListPatch <T>(Capacity);

            System.Array.Copy(this.Array, Count - count, list.Array, 0, count);
            list.Count = count;
            Count     -= count;
            Version++;

            return(list);
        }
Ejemplo n.º 3
0
 public void AddRange(ListPatch <T> list, int index, int count)
 {
     AddRange(list.Array, index, count);
 }