Hash 分布均衡算法
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Hash 分布均衡算法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                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;}?
轉載于:https://www.cnblogs.com/gaobing/p/6673547.html
總結
以上是生活随笔為你收集整理的Hash 分布均衡算法的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: P2597 [ZJOI2012]灾难(t
 - 下一篇: 【6.2】hibernate_compo