exip  Alpha 0.5.4
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
hashtable.h File Reference
#include "exipConfig.h"
#include "procTypes.h"

Go to the source code of this file.

Functions

uint32_t djbHash (String str)
 DJB Hash Function An algorithm produced by Professor Daniel J. More...
 
struct hashtablecreate_hashtable (unsigned int minsize, uint32_t(*hashfn)(String key), boolean(*eqfn)(const String str1, const String str2))
 
errorCode hashtable_insert (struct hashtable *h, String key, Index value)
 
Index hashtable_search (struct hashtable *h, String key)
 
Index hashtable_remove (struct hashtable *h, String key)
 
unsigned int hashtable_count (struct hashtable *h)
 
void hashtable_destroy (struct hashtable *h)
 

Function Documentation

struct hashtable* create_hashtable ( unsigned int  minsize,
uint32_t(*)(String key)  hashfn,
boolean(*)(const String str1, const String str2)  eqfn 
)

Definition at line 44 of file hashtable.c.

uint32_t djbHash ( String  str)

Bernstein and shown first to the world on the usenet newsgroup comp.lang.c. It is one of the most efficient hash functions ever published.

djb2 this algorithm (k=33) was first reported by dan bernstein many years ago in comp.lang.c. another version of this algorithm (now favored by bernstein) uses xor: hash(i) = hash(i - 1) * 33 ^ str[i]; the magic of number 33 (why it works better than many other constants, prime or not) has never been adequately explained.

Definition at line 28 of file hashtable.c.

unsigned int hashtable_count ( struct hashtable h)

Definition at line 144 of file hashtable.c.

void hashtable_destroy ( struct hashtable h)

Definition at line 228 of file hashtable.c.

errorCode hashtable_insert ( struct hashtable h,
String  key,
Index  value 
)

Definition at line 150 of file hashtable.c.

Index hashtable_remove ( struct hashtable h,
String  key 
)

Definition at line 193 of file hashtable.c.

Index hashtable_search ( struct hashtable h,
String  key 
)

Definition at line 175 of file hashtable.c.