more bug fixes
[IRC.git] / Robust / src / Runtime / chash.h
1 #ifndef _CHASH_H_
2 #define _CHASH_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #define INLINE    inline __attribute__((always_inline))
7 //#define INLINE
8
9 typedef struct cnode {
10   void * key;
11   void *val;       //this can be cast to another type or used to point to a larger structure
12   struct cnode *next;
13   struct cnode *lnext;
14 } cnode_t;
15
16 typedef struct ctable {
17   cnode_t *table;       // points to beginning of hash table
18   unsigned int size;
19   unsigned int mask;
20   unsigned int numelements;
21   unsigned int resize;
22   float loadfactor;
23   struct cnode *listhead;
24 } ctable_t;
25
26 /* Prototypes for hash*/
27 ctable_t *cCreate(unsigned int size, float loadfactor);
28 void cInsert(ctable_t *table, void * key, void * val);
29 void * cSearch(ctable_t *table, void * key); //returns val, NULL if not found
30 unsigned int cRemove(ctable_t *table, void * key); //returns -1 if not found
31 unsigned int cResize(ctable_t *table, unsigned int newsize);
32 void cDelete(ctable_t *table);
33 void crehash(ctable_t *table);
34 /* end hash */
35
36 #endif
37