Table of Contents

Class DynamicEqualityComparer

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

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

public static class DynamicEqualityComparer
Inheritance
Object
DynamicEqualityComparer

Methods

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

Creates a dynamic instance of an System.Collections.Generic.IEqualityComparer<T> implementation wrapping System.Collections.Generic.IEqualityComparer<T>.GetHashCode(T) through hashCalculator and System.Collections.Generic.IEqualityComparer<T>.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 System.Collections.Generic.IEqualityComparer<T> for type T.

Type Parameters

T

The type of objects to compare.

Remarks

The function delegate, hashCalculator (System.Collections.Generic.IEqualityComparer<T>.GetHashCode(T)), is evaluated with a conditional-AND before the second function delegate, equalityComparer (System.Collections.Generic.IEqualityComparer<T>.Equals(T, T)), is ivoked.