mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-12-14 00:40:26 +00:00
GetHashCode
This commit is contained in:
@@ -57,7 +57,25 @@ namespace Esiur.Data
|
|||||||
//e6 = data[offset++];
|
//e6 = data[offset++];
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID(byte[] data) {
|
public unsafe override int GetHashCode()
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
fixed (byte* p = Data)
|
||||||
|
{
|
||||||
|
ulong u0 = *(ulong*)p;
|
||||||
|
ulong u1 = *(ulong*)(p + 8);
|
||||||
|
|
||||||
|
// simple mixing of two 64-bit halves
|
||||||
|
return ((int)u0 ^ (int)(u0 >> 32)) ^
|
||||||
|
((int)u1 ^ (int)(u1 >> 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID(byte[] data)
|
||||||
|
{
|
||||||
|
|
||||||
if (data.Length != 16)
|
if (data.Length != 16)
|
||||||
throw new Exception("UUID data size must be 16 bytes");
|
throw new Exception("UUID data size must be 16 bytes");
|
||||||
@@ -88,7 +106,15 @@ namespace Esiur.Data
|
|||||||
//return $"{a1.ToString("x2")}{a2.ToString("x2")}{a3.ToString("x2")}{a4.ToString("x2")}-{b1.ToString("x2")}{b2.ToString("x2")}-{c1.ToString("x2")}{c2.ToString("x2")}-{d1.ToString("x2")}{d2.ToString("x2")}-{e1.ToString("x2")}{e2.ToString("x2")}{e3.ToString("x2")}{e4.ToString("x2")}{e5.ToString("x2")}{e6.ToString("x2")}";
|
//return $"{a1.ToString("x2")}{a2.ToString("x2")}{a3.ToString("x2")}{a4.ToString("x2")}-{b1.ToString("x2")}{b2.ToString("x2")}-{c1.ToString("x2")}{c2.ToString("x2")}-{d1.ToString("x2")}{d2.ToString("x2")}-{e1.ToString("x2")}{e2.ToString("x2")}{e3.ToString("x2")}{e4.ToString("x2")}{e5.ToString("x2")}{e6.ToString("x2")}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator == (UUID a, UUID b)
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj is UUID b)
|
||||||
|
return Data.SequenceEqual(b.Data);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator ==(UUID a, UUID b)
|
||||||
{
|
{
|
||||||
return a.Data.SequenceEqual(b.Data);
|
return a.Data.SequenceEqual(b.Data);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<Copyright>Ahmed Kh. Zamil</Copyright>
|
<Copyright>Ahmed Kh. Zamil</Copyright>
|
||||||
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
<PackageProjectUrl>http://www.esiur.com</PackageProjectUrl>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>2.4.13</Version>
|
<Version>2.4.14</Version>
|
||||||
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
|
<RepositoryUrl>https://github.com/esiur/esiur-dotnet</RepositoryUrl>
|
||||||
<Authors>Ahmed Kh. Zamil</Authors>
|
<Authors>Ahmed Kh. Zamil</Authors>
|
||||||
<AssemblyVersion></AssemblyVersion>
|
<AssemblyVersion></AssemblyVersion>
|
||||||
|
|||||||
Reference in New Issue
Block a user