zoukankan      html  css  js  c++  java
  • 开放地址法

    在开放地址法中,所有的元素都存放在哈希表里,也就是,每个表项或包含动态集合的一个元素,或包含NIL
    int locate(int s)
    {
        int h;
        h=Hash(s);
        while (use[h]&&pst[h]!=s)
        {
            h++;
            if (h>=max) h-=max;
        }
        return h;
    }
    

    void insert(int s)
    {
        int posi=locate(s);
        if (!use[posi])
        {
            use[posi]=1;
            pst[posi]=s;
        }
    }
    
    void delete(int s)
    {
        int posi=locate(s);
        if (use[posi]&&psw[posi]==s)
            use[posi]=0;
    }
    
    bool search(int s)
    {
        int posi=locate(s);
        if (use[posi]&&psw[posi]==s)
            return true;
        else
            return false;
    }
    

    ELFHash

    unsigned int ELFHash(char *str)
    {
    	unsigned int hash = 0,x	= 0;
    	while (*str)
    	{
    		hash = (hash << 4) + (*str++);
    		if ((x = hash & 0xF0000000L) != 0)
    		{
    			hash ^= (x >> 24);
    			hash &= ~x;
    		}
    	}
     
    	return (hash & 0x7FFFFFFF);
    }
    




  • 相关阅读:
    test14
    test13
    test12
    test11
    Xcode常用快捷键
    OC弱语法
    对象的结构体属性的成员修改
    IOS 获取手机各种信息
    IOS app启动过程
    iOS退出键盘的两种方式
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5835026.html
Copyright © 2011-2022 走看看