Creates a new instance of CircularSortedListTKey, TValue, that initializes its elements from the provided dictionary,
and uses the specified comparer.
Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-preview.3
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
Exception | Condition |
---|---|
ArgumentNullException | dictionary is . |
ArgumentException | dictionary 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