/ src / Ryujinx.Common / Hash128.cs
Hash128.cs
 1  using System;
 2  using System.Runtime.InteropServices;
 3  
 4  namespace Ryujinx.Common
 5  {
 6      [StructLayout(LayoutKind.Sequential)]
 7      public struct Hash128 : IEquatable<Hash128>
 8      {
 9          public ulong Low;
10          public ulong High;
11  
12          public Hash128(ulong low, ulong high)
13          {
14              Low = low;
15              High = high;
16          }
17  
18          public readonly override string ToString()
19          {
20              return $"{High:x16}{Low:x16}";
21          }
22  
23          public static bool operator ==(Hash128 x, Hash128 y)
24          {
25              return x.Equals(y);
26          }
27  
28          public static bool operator !=(Hash128 x, Hash128 y)
29          {
30              return !x.Equals(y);
31          }
32  
33          public readonly override bool Equals(object obj)
34          {
35              return obj is Hash128 hash128 && Equals(hash128);
36          }
37  
38          public readonly bool Equals(Hash128 cmpObj)
39          {
40              return Low == cmpObj.Low && High == cmpObj.High;
41          }
42  
43          public readonly override int GetHashCode()
44          {
45              return HashCode.Combine(Low, High);
46          }
47      }
48  }