标签:div int abs hash tin 移位 dex log mat
1.移位实现
public static int GetIndex(string str, int count) { int hash = str.Aggregate(23, (current, c) => (current << 5) - current + c); if (hash < 0) { hash = Math.Abs(hash); } return hash % count; }
2.GetHashCode()
public static int GetIndex2(string str, int count) { int hash =str.GetHashCode(); if (hash < 0) { hash = Math.Abs(hash); } return hash % count; }
标签:div int abs hash tin 移位 dex log mat
原文地址:http://www.cnblogs.com/gaobing/p/6673547.html