Class ProjectionComparer<TSource, TKey>
Comparer which projects each element of the comparison to a key, and then compares those keys using the specified (or default) comparer for the key type.
Namespace: Unity.UIWidgets.Runtime.external
Syntax
public class ProjectionComparer<TSource, TKey> : IComparer<TSource>
Type Parameters
| Name | Description |
|---|---|
| TSource | Type of elements which this comparer will be asked to compare |
| TKey | Type of the key projected from the element |
Constructors
ProjectionComparer(Func<TSource, TKey>)
Creates a new instance using the specified projection, which must not be null. The default comparer for the projected type is used.
Declaration
public ProjectionComparer(Func<TSource, TKey> projection)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TSource, TKey> | projection | Projection to use during comparisons |
ProjectionComparer(Func<TSource, TKey>, IComparer<TKey>)
Creates a new instance using the specified projection, which must not be null.
Declaration
public ProjectionComparer(Func<TSource, TKey> projection, IComparer<TKey> comparer)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TSource, TKey> | projection | Projection to use during comparisons |
| IComparer<TKey> | comparer | The comparer to use on the keys. May be null, in which case the default comparer will be used. |
Methods
Compare(TSource, TSource)
Compares x and y by projecting them to keys and then comparing the keys. Null values are not projected; they obey the standard comparer contract such that two null values are equal; any null value is less than any non-null value.
Declaration
public int Compare(TSource x, TSource y)
Parameters
| Type | Name | Description |
|---|---|---|
| TSource | x | |
| TSource | y |
Returns
| Type | Description |
|---|---|
| Int32 |