9 #define PLOADFACTOR 0.25
10 #define PHASH_SIZE 1024
12 typedef struct prehashlistnode {
14 void *val; //this can be cast to another type or used to point to a larger structure
15 struct prehashlistnode *next;
20 volatile unsigned int lock;
24 #define PRENUMLOCKS 16
25 #define PRELOCKMASK (PRENUMLOCKS-1)
30 typedef struct prehashtable {
31 prehashlistnode_t *table; // points to beginning of hash table
34 unsigned int numelements;
35 unsigned int threshold;
37 struct prelockarray larray[PRENUMLOCKS];
40 /* Prototypes for hash*/
41 unsigned int prehashCreate(unsigned int size, float loadfactor);
42 unsigned int prehashFunction(unsigned int key);
43 void prehashInsert(unsigned int key, void *val);
44 void *prehashSearch(unsigned int key); //returns val, NULL if not found
45 unsigned int prehashRemove(unsigned int key); //returns -1 if not found
46 unsigned int prehashResize(unsigned int newsize);