CircularSortedListTKey, TValueCapacity Property

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


Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-rc.1
public int Capacity { get; set; }

Property Value



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

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 CircularListT 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 CircularSortedListTKey, TValue, 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 array in the internal CircularListT 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 new capacity.


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

See Also