2023-12-04 13:17:13 +00:00
|
|
|
using System;
|
2020-11-12 23:15:34 +00:00
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Ryujinx.Common
|
|
|
|
{
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
public struct Hash128 : IEquatable<Hash128>
|
|
|
|
{
|
|
|
|
public ulong Low;
|
|
|
|
public ulong High;
|
|
|
|
|
2021-08-26 21:50:28 +00:00
|
|
|
public Hash128(ulong low, ulong high)
|
|
|
|
{
|
|
|
|
Low = low;
|
|
|
|
High = high;
|
|
|
|
}
|
|
|
|
|
2023-06-28 16:41:38 +00:00
|
|
|
public readonly override string ToString()
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
|
|
|
return $"{High:x16}{Low:x16}";
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool operator ==(Hash128 x, Hash128 y)
|
|
|
|
{
|
|
|
|
return x.Equals(y);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool operator !=(Hash128 x, Hash128 y)
|
|
|
|
{
|
|
|
|
return !x.Equals(y);
|
|
|
|
}
|
|
|
|
|
2023-06-28 16:41:38 +00:00
|
|
|
public readonly override bool Equals(object obj)
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
|
|
|
return obj is Hash128 hash128 && Equals(hash128);
|
|
|
|
}
|
|
|
|
|
2023-06-28 16:41:38 +00:00
|
|
|
public readonly bool Equals(Hash128 cmpObj)
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
|
|
|
return Low == cmpObj.Low && High == cmpObj.High;
|
|
|
|
}
|
|
|
|
|
2023-06-28 16:41:38 +00:00
|
|
|
public readonly override int GetHashCode()
|
2020-11-12 23:15:34 +00:00
|
|
|
{
|
|
|
|
return HashCode.Combine(Low, High);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|