This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 #ifndef _MLOOKUP_H_
2 #define _MLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define LOADFACTOR 0.5
9 #define HASH_SIZE 100
10
11 typedef struct mhashlistnode {
12         unsigned int key;
13         void *val; //this can be cast to another type or used to point to a larger structure
14         struct mhashlistnode *next;
15 } mhashlistnode_t;
16
17 typedef struct mhashtable {
18         mhashlistnode_t *table; // points to beginning of hash table
19         unsigned int size;
20         unsigned int numelements;
21         float loadfactor;
22         pthread_mutex_t locktable;
23 } mhashtable_t;
24
25 unsigned int mhashCreate(unsigned int size, float loadfactor);
26 unsigned int mhashFunction(unsigned int key);
27 unsigned mhashInsert(unsigned int key, void *val);
28 void *mhashSearch(unsigned int key); //returns val, NULL if not found
29 unsigned int mhashRemove(unsigned int key); //returns -1 if not found
30 unsigned int mhashResize(unsigned int newsize);
31 unsigned int *mhashGetKeys(unsigned int *numKeys);
32 void mhashPrint();
33
34 #endif
35