CircularListTEnsureCapacity Method

Ensures that the Capacity of the CircularListT is at least the specified capacity.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public int EnsureCapacity(
	int capacity
)

Parameters

capacity  Int32
The minimum capacity to ensure.

Return Value

Int32
The new capacity of the CircularListT.

Remarks

If the specified capacity is less than or equal to the current Capacity, then the Capacity is left unchanged.

If the specified capacity is less than twice of the current Capacity, then current Capacity is doubled.

If the specified capacity is at least twice of the current Capacity, then Capacity is set to the specified capacity.

If capacity is changed, then this method is an O(n) operation where n is Count. If capacity is not changed, then this method is an O(1) operation.

Exceptions

ArgumentOutOfRangeExceptioncapacity must not be negative.

See Also