Last active
May 6, 2020 10:09
-
-
Save korchoon/e21ab6dfea73029f1d8e075e13e2fde6 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
| static class DirtyUtils { | |
| static bool Same<T1, T2>(ref int hash, in T1 v1, in T2 v2) { | |
| var prev = hash; | |
| hash = v1.GetHashCode(); | |
| hash = (hash * 397) ^ v2.GetHashCode(); | |
| return hash == prev; | |
| } | |
| public static int HashCode<T1, T2>(in T1 v1, in T2 v2) { | |
| var hash = v1.GetHashCode(); | |
| hash = (hash * 397) ^ v2.GetHashCode(); | |
| return hash; | |
| } | |
| public static int HashCode<T1, T2, T3>(in T1 v1, in T2 v2, in T3 v3) { | |
| var hash = v1.GetHashCode(); | |
| hash = (hash * 397) ^ v2.GetHashCode(); | |
| hash = (hash * 397) ^ v3.GetHashCode(); | |
| return hash; | |
| } | |
| public static int HashCode<T1, T2, T3, T4>(in T1 v1, in T2 v2, in T3 v3, in T4 v4) | |
| { | |
| var hash = v1.GetHashCode(); | |
| hash = (hash * 397) ^ v2.GetHashCode(); | |
| hash = (hash * 397) ^ v3.GetHashCode(); | |
| hash = (hash * 397) ^ v4.GetHashCode(); | |
| return hash; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment