Add Il2CppEqualityComparer

This commit is contained in:
js6pak committed 2021-04-08 22:01:50 +02:00
1 parent e9aa92afcb
commit f5999a3577
1 file changed
+38
+38
View File
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using Il2CppSystem.Runtime.CompilerServices;
namespace Reactor
{
public sealed class Il2CppEqualityComparer<T> : IEqualityComparer<T> where T : Il2CppSystem.Object
{
private static Il2CppEqualityComparer<T> _instance;
public static Il2CppEqualityComparer<T> Instance
{
get
{
_instance ??= new Il2CppEqualityComparer<T>();
return _instance;
}
}
private Il2CppEqualityComparer()
{
}
public int GetHashCode(T value)
{
return RuntimeHelpers.GetHashCode(value);
}
public bool Equals(T left, T right)
{
if (left == null || right == null)
{
return left == null && right == null;
}
return left.Equals(right);
}
}
}