Skip to content

Instantly share code, notes, and snippets.

@LiSheep
LiSheep / hash_function
Created June 5, 2016 12:40
some hash function
// 一种简单快捷的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) {
@koblas
koblas / echo.cxx
Created August 15, 2012 22:46
libev c++ echo server
#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>