CircularSortedListTKey, TValue(IDictionaryTKey, TValue, IComparerTKey) Constructor

Creates a new instance of CircularSortedListTKey, TValue, that initializes its elements from the provided dictionary, and uses the specified comparer.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public CircularSortedList(
	IDictionary<TKey, TValue> dictionary,
	IComparer<TKey>? comparer = null
)

Parameters

dictionary  IDictionaryTKey, TValue
The IDictionaryTKey, TValue whose elements are copied to the new SCircularSortedListTKey, TValue.
comparer  IComparerTKey  (Optional)
The IComparerT implementation to use when comparing keys. If , EnumComparer<TEnum>.Comparer will be used for enum TKey types when targeting the .NET Framework, or Comparer<T>.Default in other cases. This parameter is optional.
Default value: .

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.

Exceptions

ArgumentNullExceptiondictionary is .
ArgumentExceptiondictionary contains one or more duplicate keys.

See Also