CircularListTReplaceRange Method

Removes count amount of items from the CircularListT at the specified index and inserts the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public void ReplaceRange(
	int index,
	int count,
	IEnumerable<T> collection
)

Parameters

index  Int32
The zero-based index of the first item to remove and also the index at which collection items should be inserted.
count  Int32
The number of items to remove.
collection  IEnumerableT
The collection to insert into the list.

Implements

ISupportsRangeListTReplaceRange(Int32, Int32, IEnumerableT)

Remarks

If the length of the CircularListT is n and the length of the collection to insert is m, then replacement at the first or last position has O(m) cost.

If the elements to remove and to add have the same size, then the cost is O(m) at any position.

If capacity increase is needed (considering actual list size), or when the replacement of different amount of elements to remove and insert is performed in the middle of the CircularListT, the cost is O(Max(n, m)), and in practice no more than n/2 elements are moved.

Exceptions

ArgumentOutOfRangeExceptionindex is not a valid index in the CircularListT.
ArgumentNullExceptioncollection must not be .

See Also