霍纳算法的散列函数

    //霍纳算法的散列函数
    function betterHash(string,arr) {
        const H = 37;
        var total=0;
        for (var i = 0; i < string.length; i++) {
            total +=  H * total + string.charCodeAt(i);
        }
        total =total % this.table.length;
        if(total<0)
        {
            total +=this.table.length-1;
        }
        return parseInt(total);
    }
好好学习,天天向上。
原文地址:https://www.cnblogs.com/Zhengxue/p/6141413.html