BKDRHash函数

unsigned int BKDRHash(char*str)   
{   
    unsigned int seed=131 ;// 31 131 1313 13131 131313 etc..    
    unsigned int hash=0 ;   
       
    while(*str)   
    {   
        hash=hash*seed+(*str++);   
    }   
       
    return(hash % maxn);   
}  
template<class T>  
size_t BKDRHash(const T *str)  
{  
    register size_t hash = 0;  
    while (size_t ch = (size_t)*str++)  
        hash = hash * 131 + ch;   // 也可以乘以31、131、1313、13131、131313..            
    return hash;  
}  
原文地址:https://www.cnblogs.com/weeping/p/5758385.html