mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Add Il2CppEqualityComparer
This commit is contained in:
1 parent
e9aa92afcb
commit
f5999a3577
1 file changed
+38
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user