57 unsigned int amxc_RS_hash(
const char* str,
const unsigned int len) {
58 unsigned int b = 378551;
59 unsigned int a = 63689;
60 unsigned int hash = 0;
63 for(i = 0; i < len; str++, i++) {
64 hash = hash * a + (*str);
71 unsigned int amxc_JS_hash(
const char* str,
const unsigned int len) {
72 unsigned int hash = 1315423911;
75 for(i = 0; i < len; str++, i++) {
76 hash ^= ((hash << 5) + (*str) + (hash >> 2));
83 const unsigned int BitsInUnsignedInt = (
unsigned int) (
sizeof(
unsigned int) * 8);
84 const unsigned int ThreeQuarters = (
unsigned int) ((BitsInUnsignedInt * 3) / 4);
85 const unsigned int OneEighth = (
unsigned int) (BitsInUnsignedInt / 8);
86 const unsigned int HighBits = (
unsigned int) (0xFFFFFFFF) << (BitsInUnsignedInt - OneEighth);
87 unsigned int hash = 0;
88 unsigned int test = 0;
91 for(i = 0; i < len; str++, i++) {
92 hash = (hash << OneEighth) + (*str);
94 if((test = hash & HighBits) != 0) {
95 hash = (( hash ^ (test >> ThreeQuarters)) & (~HighBits));
103 unsigned int hash = 0;
107 for(i = 0; i < len; str++, i++) {
108 hash = (hash << 4) + (*str);
109 if((x = hash & 0xF0000000L) != 0) {
119 unsigned int seed = 131;
120 unsigned int hash = 0;
123 for(i = 0; i < len; str++, i++) {
124 hash = (hash * seed) + (*str);
131 unsigned int hash = 0;
134 for(i = 0; i < len; str++, i++) {
135 hash = (*str) + (hash << 6) + (hash << 16) - hash;
142 unsigned int hash = 5381;
145 for(i = 0; i < len; str++, i++) {
146 hash = ((hash << 5) + hash) + (*str);
153 unsigned int hash = len;
156 for(i = 0; i < len; str++, i++) {
157 hash = ((hash << 5) ^ (hash >> 27)) ^ (*str);
163 unsigned int hash = 0;
165 for(i = 0; i < len; str++, i++) {
166 hash = hash << 7 ^ (*str);
173 const unsigned int fnv_prime = 0x811C9DC5;
174 unsigned int hash = 0;
177 for(i = 0; i < len; str++, i++) {
179 hash ^= (int) (*str);
186 unsigned int hash = 0xAAAAAAAA;
189 for(i = 0; i < len; str++, i++) {
190 hash ^= ((i & 1) == 0) ? ((hash << 7) ^ (*str) * (hash >> 3)) :
191 (~((hash << 11) + ((*str) ^ (hash >> 5))));
Ambiorix string hash functions header file.
unsigned int amxc_BKDR_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_ELF_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_DEK_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_FNV_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_BP_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_RS_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_SDBM_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_JS_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_AP_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_DJB_hash(const char *str, const unsigned int len)
Calculate a hash from a string.
unsigned int amxc_PJW_hash(const char *str, const unsigned int len)
Calculate a hash from a string.