KGy SOFT

CircularSortedListTKey, TValue Constructor (IDictionaryTKey, TValue, IComparerTKey)

KGy SOFT Core Libraries Help

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

public CircularSortedList(
	IDictionary<TKey, TValue> dictionary,
	IComparer<TKey>? comparer = null
)

Parameters

dictionary
Type: System.Collections.GenericIDictionaryTKey, TValue
The IDictionaryTKey, TValue whose elements are copied to the new SCircularSortedListTKey, TValue.
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
ArgumentNullExceptiondictionary is .
ArgumentExceptiondictionary contains one or more duplicate keys.
Remarks

Every key in a CircularSortedListTKey, TValue must be unique according to the specified comparer; likewise, every key in the source dictionary must also be unique according to the specified comparer.

The capacity of the new CircularSortedListTKey, TValue is set to the number of elements in dictionary, so no resizing takes place while the list is being populated.

If the data in dictionary are sorted, this constructor is an O(n) operation, where n is the number of elements in dictionary. Otherwise it is an O(n*n) operation.

See Also

Reference