开放地址法
在開放地址法中,所有的元素都存放在哈希表里,也就是,每個(gè)表項(xiàng)或包含動(dòng)態(tài)集合的一個(gè)元素,或包含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;elsereturn false; }
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;elsereturn 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); }轉(zhuǎn)載于:https://www.cnblogs.com/lgh1992314/archive/2013/05/23/5835026.html
總結(jié)
- 上一篇: 配置事务springmvc3.1 myb
- 下一篇: win7配置Eclipse+Cocos2