Click or drag to resize

RankedMapTKey, TValue Constructor (IComparerTKey)

Initializes a new map instance using the supplied key comparer.

Namespace:  Kaos.Collections
Assembly:  KaosCollections (in KaosCollections.dll) Version: 4.2.0.0
Syntax
C#
public RankedMap(
	IComparer<TKey> comparer
)

Parameters

comparer
Type: System.Collections.GenericIComparerTKey
Comparison operator for keys.
Exceptions
ExceptionCondition
InvalidOperationExceptionWhen comparer is null and no other comparer available.
Remarks

This class requires an IComparer implementation to perform key comparisons. If comparer is null, the default comparer for the type will be used. If the key type implements the IComparableinterface, the default comparer uses that implementation. If no comparison implementation is available, the Add method will fail on the second element.

Examples
The below snippet is part of a larger example of the RankedMapTKey, TValueclass. This example creates a map with case insensitive sorting of keys.
C#
// Keys will compare case insensitive with this constructor.
var fmt = new RankedMap<string,string> (StringComparer.InvariantCultureIgnoreCase);
See Also