mirror of
https://gitee.com/xiarenalofs/squad-rain-ops-mini.git
synced 2026-08-09 22:55:57 +08:00
31 lines
772 B
C#
31 lines
772 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RainOpsMini.Helpers
|
|
{
|
|
public static class HashHelper
|
|
{
|
|
public static int GetDeterministicHashCode(this string str)
|
|
{
|
|
unchecked
|
|
{
|
|
int hash1 = (5381 << 16) + 5381;
|
|
int hash2 = hash1;
|
|
|
|
for (int i = 0; i < str.Length; i += 2)
|
|
{
|
|
hash1 = ((hash1 << 5) + hash1) ^ str[i];
|
|
if (i == str.Length - 1)
|
|
break;
|
|
hash2 = ((hash2 << 5) + hash2) ^ str[i + 1];
|
|
}
|
|
|
|
return hash1 + (hash2 * 1566083941);
|
|
}
|
|
}
|
|
}
|
|
}
|