Created
June 18, 2014 10:46
-
-
Save alfredodev/db10370efc03f647378f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PredicateEqualityComparer<T> : EqualityComparer<T> | |
| { | |
| private readonly Func<T, T, bool> predicate; | |
| public PredicateEqualityComparer(Func<T, T, bool> predicate) | |
| { | |
| this.predicate = predicate; | |
| } | |
| public override bool Equals(T x, T y) | |
| { | |
| if (x != null) | |
| { | |
| return ((y != null) && predicate(x, y)); | |
| } | |
| if (y != null) | |
| { | |
| return false; | |
| } | |
| return true; | |
| } | |
| public override int GetHashCode(T obj) | |
| { | |
| return 0; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment