CircularListTCapacity Property

Gets or sets the actual size of the internal storage of held elements.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public int Capacity { get; set; }

Property Value

Int32

Remarks

Capacity is the number of elements that the CircularListT can store before resizing is required, whereas Count is the number of elements that are actually in the CircularListT.

Capacity is always greater than or equal to Count. If Count exceeds Capacity while adding elements, the capacity is increased by automatically reallocating the internal array before copying the old elements and adding the new elements.

If the capacity is significantly larger than the count and you want to reduce the memory used by the CircularListT, you can decrease capacity by calling the TrimExcess method or by setting the Capacity property explicitly. When the value of Capacity is set explicitly, the internal array is also reallocated to accommodate the specified capacity, and all the elements are copied.

Retrieving the value of this property is an O(1) operation; setting the property is an O(n) operation, where n is the number of stored elements.

Exceptions

ArgumentOutOfRangeExceptionCapacity is set to a value that is less than Count.

See Also