CircularSortedListTKey, TValue Constructor (Int32, IComparerTKey)

KGy SOFT Core Libraries Help

Namespace:  KGySoft.Collections
Assembly:  KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-preview.3

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


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: .

ArgumentOutOfRangeExceptioncapacity is less than 0.

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