Class ProjectionComparer<TSource, TKey> | UIWidgets | 1.5.4-preview.12
docs.unity3d.com
    Show / Hide Table of Contents

    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.

    Inheritance
    Object
    ProjectionComparer<TSource, TKey>
    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
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023