Hash128.cs 1.0 KB

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