Table of Contents

Class DynamicEqualityComparer

Namespace
Cuemon.Collections.Generic
Assembly
Cuemon.Core.dll

Provides a factory based way to create and wrap an IEqualityComparer<T> implementation.

public static class DynamicEqualityComparer
Inheritance
DynamicEqualityComparer

Methods

Create<T>(Func<T, Int32>, Func<T, T, Boolean>)

Creates a dynamic instance of an IEqualityComparer<T> implementation wrapping GetHashCode(T) through hashCalculator and Equals(T, T). through equalityComparer.

public static IEqualityComparer<T> Create<T>(Func<T, int> hashCalculator, Func<T, T, bool> equalityComparer)

Parameters

hashCalculator Func<T, Int32>

The function delegate that calculates a hash code of the specified object and is invoked first.

equalityComparer Func<T, T, Boolean>

The function delegate that determines whether the specified objects are equal. This delegate is invoked second if qualified.

Returns

IEqualityComparer<T>

A dynamic instance of IEqualityComparer<T> for type T.

Type Parameters

T

The type of objects to compare.

Remarks

The function delegate, hashCalculator (GetHashCode(T)), is evaluated with a conditional-AND before the second function delegate, equalityComparer (Equals(T, T)), is ivoked.