// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System.Collections.Generic;
namespace System.Windows.Controls.DataVisualization
{
///
/// A generic equality comparer.
///
/// The type of the objects being compared.
internal class GenericEqualityComparer : EqualityComparer
{
///
/// Gets or sets a function which determines whether two items are equal.
///
public Func EqualityFunction { get; set; }
///
/// Gets or sets a function that returns a hash code for an object.
///
public Func HashCodeFunction { get; set; }
///
/// Initializes a new instance of the GenericEqualityComparer class.
///
/// A function which determines whether
/// two items are equal.
/// A function that returns a hash code
/// for an object.
public GenericEqualityComparer(Func equalityFunction, Func hashCodeFunction)
{
this.EqualityFunction = equalityFunction;
this.HashCodeFunction = hashCodeFunction;
}
///
/// A function which determines whether two items are equal.
///
/// The left object.
/// The right object.
/// A value indicating whether the objects. are equal.
public override bool Equals(T x, T y)
{
return EqualityFunction(x, y);
}
///
/// A function that returns a hash code for an object.
///
/// The object to returns a hash code for.
/// The hash code for the object.
public override int GetHashCode(T obj)
{
return HashCodeFunction(obj);
}
}
}