Table of Contents

Class QuickEqualityComparer<TElement>

Namespace
Utils.Objects
Assembly
Utils.dll

A helper class to encapsulate element equality and hash logic, optimizing for IEquatable<T>, IComparable<T>, and array types.

public sealed class QuickEqualityComparer<TElement> : IEqualityComparer<TElement>

Type Parameters

TElement
Inheritance
QuickEqualityComparer<TElement>
Implements
Inherited Members
Extension Methods

Constructors

QuickEqualityComparer(Func<TElement, TElement, bool>, Func<TElement, int>)

Initializes a new instance of the QuickEqualityComparer<TElement> class.

public QuickEqualityComparer(Func<TElement, TElement, bool> comparer, Func<TElement, int> hasher = null)

Parameters

comparer Func<TElement, TElement, bool>

Delegate that determines whether two values are equal.

hasher Func<TElement, int>

Optional delegate used to compute the hash code for a value.

Fields

Instance

Gets a cached IEqualityComparer<T> instance suited for TElement.

public static readonly IEqualityComparer<TElement> Instance

Field Value

IEqualityComparer<TElement>

Methods

Equals(TElement?, TElement?)

Compares two values using the delegate provided during construction.

public bool Equals(TElement? x, TElement? y)

Parameters

x TElement

The first value to compare.

y TElement

The second value to compare.

Returns

bool

true when the values are considered equal; otherwise, false.

GetHashCode(TElement)

Computes the hash code for the specified value.

public int GetHashCode(TElement obj)

Parameters

obj TElement

The value for which to compute a hash code.

Returns

int

A hash code produced by the configured hashing delegate.