This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <fcntl.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ev++.h> | |
#include <netinet/in.h> | |
#include <sys/socket.h> | |
#include <resolv.h> | |
#include <errno.h> | |
#include <list> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 一种简单快捷的hash算法 | |
unsigned int BKDRHash(char *str) { | |
register unsigned int hash = 0; | |
while (unsigned int ch = (unsigned int)*str++) | |
hash = hash * 131 + ch; // 也可以乘以31、131、1313、13131、131313.. | |
return hash; | |
} | |
// 开源项目SDBM使用 | |
unsigned int SDBMHash(char*str) { |