首页 > 其他 > 详细

[模板] 哈希表

时间:2018-12-20 10:58:41      阅读:114      评论:0      收藏:0      [点我收藏+]

写插头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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!