zoukankan      html  css  js  c++  java
  • 哈希表/散列表 指针版模版

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<vector>
    #include<algorithm>
    using namespace std;
    
    const int N = 2010;
    const int M = 10010;
    typedef long long LL;
    
    const int SIZE = 100003;
    const int SEED = 13333;
    
    struct Node{
        LL key;
        int type;
        Node *next;
        Node *set(LL _key,Node *_next ){
            key = _key; next = _next; type = -1;
            return this;
        }
    };
    
    Node Base[SIZE];
    
    struct Hash{
        Node *H[SIZE], *cur;
        int mark[N], cmark;
        void clear(){
            cur = Base;
            cmark++;
        }
        Hash(){
            memset(mark,0,sizeof(mark));
            cmark = 0;
        }
        int &find(LL key){
            int h = key%SEED;
            if( mark[h] < cmark ) mark[h] = cmark, H[h] = 0;
            for(Node *p = H[h]; p ; p = p->next )
                if( p->key == key ) return p->type;
            H[h] = (cur++)->set(key,H[h]);
            return H[h]->type;
        }
    }H;
    
    int main(){
    
        return 0;
    }
  • 相关阅读:
    dup/dup2函数
    read/write函数
    lseek函数
    流程控制
    vim普通模式
    vim实用技巧1
    python源代码解读
    python变量命名规则
    python之字符串2
    Docker系列文章
  • 原文地址:https://www.cnblogs.com/yefeng1627/p/3228355.html
Copyright © 2011-2022 走看看