/*
 *  hashpjw, algorithm by P.J.Weinberg
 *
 *  03.06.1998, implemented by Michael Neumann
 */

int hashpjw(int M, char* t)
{
    unsigned h=0, g;
    for(;*t;++t) {
        h = (h << 4)+ *t;
        if(g=h&0xf0000000) {
            h ^= g>>24;
            h ^= g;
        }
    }
    return h%M;
}