Added minimum size analysis.
[repair.git] / Repair / RepairCompiler / structextract / GenericHashtable.h
1 // implements a generic hash table
2
3 #ifndef GENHASHTABLE
4 #define GENHASHTABLE
5 #define geninitialnumbins 10
6 #define bool int
7
8 struct genhashtable {
9   unsigned int (*hash_function)(void *);
10   int (*comp_function)(void *,void *);
11   struct genpointerlist ** bins;
12   long counter;
13   int currentsize;
14   struct genpointerlist *list;
15   struct genpointerlist *last;
16 };
17
18
19 struct genpointerlist {
20   void * src;
21   void * object;
22   struct genpointerlist * next;
23
24   struct genpointerlist * inext;
25   struct genpointerlist * iprev;
26 };
27
28
29 struct geniterator {
30   struct genpointerlist * ptr;
31   bool finished;
32 };
33
34 struct genhashtable * genallocatehashtable(unsigned int (*hash_function)(void *),int (*comp_function)(void *,void *));
35 void genfreehashtable(struct genhashtable * ht);
36
37 void * getnext(struct genhashtable *,void *);
38 int genputtable(struct genhashtable *, void *, void *);
39 void * gengettable(struct genhashtable *, void *);
40 int gencontains(struct genhashtable *, void *);
41 unsigned int genhashfunction(struct genhashtable *,void *);
42
43 int hashsize(struct genhashtable * ht);
44 void genfreekey(struct genhashtable *ht, void *);
45 struct geniterator * gengetiterator(struct genhashtable *ht);
46 void * gennext(struct geniterator *it);
47 void genfreeiterator(struct geniterator *it);
48 #endif
49
50
51