[模板] 哈希表

写插头dp的时候写的。。

struct thash{
    int val[nmod];
    struct te{int st,pr;}e[nmod];
    int hd[nmod],pe=0;
    void adde(int f,int st){e[++pe]=(te){st,hd[f]};hd[f]=pe;}
    void init(){clear(val),clear(hd),pe=0;}
    int& get(int st){
        int p=st%nmod;
        for(int i=hd[p];i;i=e[i].pr){
            if(e[i].st==st)return val[i];
        }
        adde(p,st);
        return val[hd[p]];
    }
}table;
原文地址:https://www.cnblogs.com/ubospica/p/10147951.html