Table of Contents

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

T

The type of elements in the sequences. Must be comparable.

Inheritance
EnumerableComparer<T>
Implements
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

elementComparer IComparer<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

x IEnumerable<T>

The first object to compare.

y IEnumerable<T>

The second object to compare.

Returns

int

A signed integer that indicates the relative values of x and y, as shown in the following table.

Value Meaning
Less than zerox is less than y.
Zerox equals y.
Greater than zerox is greater than y.