This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 #ifndef _LLOOKUP_H_
2 #define _LLOOKUP_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <pthread.h>
7
8 #define SIMPLE_LLOOKUP
9
10 #define LOADFACTOR 0.5
11 #define HASH_SIZE 100
12
13 typedef struct lhashlistnode {
14         unsigned int oid;
15         unsigned int mid;
16         struct lhashlistnode *next;
17 } lhashlistnode_t;
18
19 typedef struct lhashtable {
20         lhashlistnode_t *table; // points to beginning of hash table
21         unsigned int size;
22         unsigned int numelements;
23         float loadfactor;
24         pthread_mutex_t locktable;
25 } lhashtable_t;
26
27 //returns 0 for success and 1 for failure
28 unsigned int lhashCreate(unsigned int size, float loadfactor);
29 //returns 0 for success and 1 for failure
30 unsigned int lhashInsert(unsigned int oid, unsigned int mid);
31 //returns mid, 0 if not found
32 unsigned int lhashSearch(unsigned int oid);
33 //returns 0 for success and 1 for failure
34 unsigned int lhashRemove(unsigned int oid);
35
36 //helper functions
37 unsigned int lhashResize(unsigned int newsize);
38 unsigned int lhashFunction(unsigned int oid);
39
40 #endif