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

Go to the source code of this file.

Macros

#define CEIL(VARIABLE)   ( ((VARIABLE) - (unsigned int)(VARIABLE))==0 ? (unsigned int)(VARIABLE) : (unsigned int) (VARIABLE)+1 )
 

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))
 
unsigned int hashtable_count (struct hashtable *h)
 
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)
 
void hashtable_destroy (struct hashtable *h)
 

Variables

const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0])
 
const float max_load_factor = 0.65F
 

Macro Definition Documentation

#define CEIL (   VARIABLE)    ( ((VARIABLE) - (unsigned int)(VARIABLE))==0 ? (unsigned int)(VARIABLE) : (unsigned int) (VARIABLE)+1 )

Definition at line 9 of file hashtable.c.

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.

Variable Documentation

const float max_load_factor = 0.65F

Definition at line 26 of file hashtable.c.

const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0])

Definition at line 25 of file hashtable.c.