Hash128.cs 942 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 override string ToString()
  11. {
  12. return $"{High:x16}{Low:x16}";
  13. }
  14. public static bool operator ==(Hash128 x, Hash128 y)
  15. {
  16. return x.Equals(y);
  17. }
  18. public static bool operator !=(Hash128 x, Hash128 y)
  19. {
  20. return !x.Equals(y);
  21. }
  22. public override bool Equals(object obj)
  23. {
  24. return obj is Hash128 hash128 && Equals(hash128);
  25. }
  26. public bool Equals(Hash128 cmpObj)
  27. {
  28. return Low == cmpObj.Low && High == cmpObj.High;
  29. }
  30. public override int GetHashCode()
  31. {
  32. return HashCode.Combine(Low, High);
  33. }
  34. }
  35. }