Initial
This commit is contained in:
commit
d6d2856c3a
8 changed files with 174 additions and 0 deletions
14
djb2.c
Normal file
14
djb2.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "hash/djb2.h"
|
||||
|
||||
/*
|
||||
* Simple hash function djb2, as in Daniel J. Berenstein.
|
||||
*/
|
||||
|
||||
uint64_t djb2(const char *str) {
|
||||
uint64_t h = 5381;
|
||||
int c;
|
||||
|
||||
while ((c = *str++)) h = ((h << 5) + h) + c; // h = h * 33 + c;
|
||||
|
||||
return h;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue