1.移位实现
public static int GetIndex(string str, int count)
{
int hash = str.Aggregate(, (current, c) => (current << ) - current + c);
if (hash < )
{
hash = Math.Abs(hash);
}
return hash % count;
}
2.GetHashCode()
public static int GetIndex2(string str, int count)
{
int hash =str.GetHashCode();
if (hash < )
{
hash = Math.Abs(hash);
}
return hash % count;
}