Class EnumerableComparer<T>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
Compares two sequences of values of comparable types. Supports custom comparers and optimizations for IReadOnlyList<T> and Span<T> where applicable.
public sealed class EnumerableComparer<T> : IComparer<IEnumerable<T>>
Type Parameters
TThe type of elements in the sequences. Must be comparable.
- Inheritance
-
EnumerableComparer<T>
- Implements
-
IComparer<IEnumerable<T>>
- Inherited Members
- Extension Methods
Constructors
EnumerableComparer(IComparer<T>)
Initializes a new instance of the EnumerableComparer<T> class using a provided element comparer.
public EnumerableComparer(IComparer<T> elementComparer)
Parameters
elementComparerIComparer<T>A comparer for elements of type
T.
Properties
Default
A thread-safe, cached instance of EnumerableComparer<T> using the default comparison logic for elements.
public static IComparer<IEnumerable<T>> Default { get; }
Property Value
- IComparer<IEnumerable<T>>
Methods
Compare(IEnumerable<T>?, IEnumerable<T>?)
Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
public int Compare(IEnumerable<T>? x, IEnumerable<T>? y)
Parameters
xIEnumerable<T>The first object to compare.
yIEnumerable<T>The second object to compare.
Returns
- int
A signed integer that indicates the relative values of
xandy, as shown in the following table.Value Meaning Less than zero xis less thany.Zero xequalsy.Greater than zero xis greater thany.