public void CopyTo(int index, MarshalArray <T> array, int arrayIndex, int count) { if (this.m_size - index < count) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } MarshalArrayBase.Copy(this.m_items, index, array, arrayIndex, count); }
public void RemoveAt(int index) { if ((uint)index >= (uint)this.m_size) { ThrowHelper.ThrowArgumentOutOfRangeException(); } --this.m_size; if (index < this.m_size) { MarshalArrayBase.Copy(this.m_items, index + 1, this.m_items, index, this.m_size - index); } this.m_items[this.m_size] = default(T); ++this.m_version; }
public void InsertRange(int index, IEnumerable <T> collection) { if (collection == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); } if ((uint)index > (uint)this.m_size) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index); } ICollection <T> objs = collection as ICollection <T>; if (objs != null) { int count = objs.Count; if (count > 0) { this.EnsureCapacity(this.m_size + count); if (index < this.m_size) { MarshalArrayBase.Copy(this.m_items, index, this.m_items, index + count, this.m_size - index); } if (this == objs) { MarshalArrayBase.Copy(this.m_items, 0, this.m_items, index, index); MarshalArrayBase.Copy(this.m_items, index + count, this.m_items, index * 2, this.m_size - index); } else { T[] array = new T[count]; objs.CopyTo(array, 0); MarshalArrayBase.Copy <T>(array, 0, m_items, index, count); } this.m_size += count; } } else { foreach (T obj in collection) { this.Insert(index++, obj); } } ++this.m_version; }
public void Insert(int index, T item) { if ((uint)index > (uint)this.m_size) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_ListInsert); } if (this.m_size == this.m_items.Length) { this.EnsureCapacity(this.m_size + 1); } if (index < this.m_size) { MarshalArrayBase.Copy(this.m_items, index, this.m_items, index + 1, this.m_size - index); } this.m_items[index] = item; ++this.m_size; ++this.m_version; }
public MarshalList <T> GetRange(int index, int count) { if (index < 0 || count < 0) { ThrowHelper.ThrowArgumentOutOfRangeException( index < 0 ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); } if (this.m_size - index < count) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } MarshalList <T> objList = new MarshalList <T>(count); MarshalArrayBase.Copy(this.m_items, index, objList.m_items, 0, count); objList.m_size = count; return(objList); }
public void RemoveRange(int index, int count) { if (index < 0 || count < 0) { ThrowHelper.ThrowArgumentOutOfRangeException(index < 0 ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum); } if (this.m_size - index < count) { ThrowHelper.ThrowArgumentException(ExceptionResource.Argument_InvalidOffLen); } if (count <= 0) { return; } this.m_size -= count; if (index < this.m_size) { MarshalArrayBase.Copy(this.m_items, index + count, this.m_items, index, this.m_size - index); } //MarshalArrayBase.Clear(this.m_items, this.m_size, count); ++this.m_version; }
public void CopyTo(MarshalArray <T> array, int arrayIndex) { MarshalArrayBase.Copy(this.m_items, 0, array, arrayIndex, this.m_size); }
public void CopyTo(Array array, int index) { MarshalArrayBase.Copy(this.m_items, 0, (T[])array, index, this.m_size); }
public T[] ToArray() { T[] objArray = new T[this.m_size]; MarshalArrayBase.Copy(this.m_items, 0, objArray, 0, this.m_size); return(objArray); }