CircularListTAdd Method

Adds an item to the end of the CircularListT.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public void Add(
	T item
)

Parameters

item  T
The item to add to the CircularListT.

Implements

ICollectionTAdd(T)

Remarks

CircularListT accepts as a valid value for reference and nullable types and allows duplicate elements.

If Count already equals Capacity, the capacity of the list is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

If Count is less than Capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count. When adding elements continuously, the amortized cost of this method is O(1) due to the low frequency of increasing capacity. For example, when 20 million items are added to a CircularListT that was created by the default constructor, capacity is increased only 23 times.

See Also