Add equality functions to UInt128

This commit is contained in:
jduncanator 2018-12-07 00:37:26 +11:00
parent 0cd5ba03fe
commit 135ef0bdd2

View file

@ -1,13 +1,15 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.Utilities
{
public struct UInt128
[StructLayout(LayoutKind.Sequential)]
public struct UInt128 : IEquatable<UInt128>
{
public long Low { get; private set; }
public long High { get; private set; }
public long Low { get; private set; }
public UInt128(long low, long high)
{
@ -41,5 +43,31 @@ namespace Ryujinx.HLE.Utilities
{
return (Low | High) == 0;
}
public static bool operator ==(UInt128 int1, UInt128 int2)
{
return int1.Equals(int2);
}
public static bool operator !=(UInt128 int1, UInt128 int2)
{
return !(int1 == int2);
}
public override bool Equals(object obj)
{
return obj is UInt128 && Equals((UInt128)obj);
}
public bool Equals(UInt128 other)
{
return High == other.High &&
Low == other.Low;
}
public override int GetHashCode()
{
return HashCode.Combine(High, Low);
}
}
}