Add equality functions to UInt128
This commit is contained in:
parent
0cd5ba03fe
commit
135ef0bdd2
1 changed files with 30 additions and 2 deletions
|
@ -1,13 +1,15 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.Utilities
|
namespace Ryujinx.HLE.Utilities
|
||||||
{
|
{
|
||||||
public struct UInt128
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct UInt128 : IEquatable<UInt128>
|
||||||
{
|
{
|
||||||
public long High { get; private set; }
|
|
||||||
public long Low { get; private set; }
|
public long Low { get; private set; }
|
||||||
|
public long High { get; private set; }
|
||||||
|
|
||||||
public UInt128(long low, long high)
|
public UInt128(long low, long high)
|
||||||
{
|
{
|
||||||
|
@ -41,5 +43,31 @@ namespace Ryujinx.HLE.Utilities
|
||||||
{
|
{
|
||||||
return (Low | High) == 0;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue