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