I’ve had nice results with djb2
by Dan Bernstein.
unsigned long
hash(unsigned char *str)
{
unsigned long hash = 5381;
int c;
while (c = *str++)
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
return hash;
}
More Related Contents:
- What integer hash function are good that accepts an integer hash key?
- Looking for a good hash table implementation in C [closed]
- Recursive and non-recursive traversal of three degree tree
- how to show time performance for merge sort? [closed]
- Why this C code makes infinite loop?
- Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C
- How to reverse a singly linked list using only two pointers?
- Unique random number generation in an integer array [duplicate]
- Calculating factorial of large numbers in C
- Hash table runtime complexity (insert, search and delete)
- Quick Way to Implement Dictionary in C
- Combine Gyroscope and Accelerometer Data
- How can I simplify this working Binary Search code in C?
- Power by squaring for negative exponents
- Explain this snippet which finds the maximum of two integers without using if-else or any other comparison operator?
- C How to “draw” a Binary Tree to the console [closed]
- Hashtable with MultiDimensional Key in C#
- How to do unsigned saturating addition in C?
- Traverse Matrix in Diagonal strips
- How can I sort a std::map first by value, then by key?
- Correctness of Sakamoto’s algorithm to find the day of week
- Rolling median in C – Turlach implementation
- Find maximum of three number in C without using conditional statement and ternary operator
- Algorithm to find all the exact divisors of a given integer
- Which is better way to calculate nCr
- Hash function for a string
- Merging two sorted linked lists
- a working non-recursive floodfill algorithm written in C?
- Algorithm to pick values from array that sum closest to a target value?
- Avoid Overflow when Calculating π by Evaluating a Series Using 16-bit Arithmetic?