KGy SOFT

CircularSortedListTKey, TValue Constructor (Int32, IComparerTKey)

KGy SOFT Core Libraries Help

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 6.0.0
Syntax

public CircularSortedList(
	int capacity,
	IComparer<TKey>? comparer = null
)

Parameters

capacity
Type: SystemInt32
The initial number of elements that the CircularSortedListTKey, TValue can contain.
comparer (Optional)
Type: System.Collections.GenericIComparerTKey
The IComparerT implementation to use when comparing keys. When , EnumComparer<TEnum>.Comparer will be used for enum TKey types, or Comparer<T>.Default for other types. This parameter is optional.
Default value: .
Exceptions

ExceptionCondition
ArgumentOutOfRangeExceptioncapacity is less than 0.
Remarks

Every key in a CircularSortedListTKey, TValue must be unique according to the specified comparer.

The capacity of a CircularSortedListTKey, TValue is the number of elements that the CircularSortedListTKey, TValue can hold before resizing. As elements are added to a CircularSortedListTKey, TValue, the capacity is automatically increased as required by reallocating the array of the internal CircularListT.

If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the CircularSortedListTKey, TValue.

The capacity can be decreased by calling TrimExcess or by setting the Capacity property explicitly. Decreasing the capacity reallocates memory and copies all the elements in the CircularSortedListTKey, TValue.

See Also

Reference