changes to runtime/etc to build in repair checking code
[IRC.git] / Robust / src / Runtime / SimpleHash.h
1 #ifndef SIMPLEHASH_H
2 #define SIMPLEHASH_H
3
4 #ifndef bool
5 #define bool int
6 #endif
7
8 #ifndef true
9 #define true 1
10 #endif
11
12 #ifndef false
13 #define false 0
14 #endif
15
16 #include "mem.h"
17
18 /* SimpleHash *********************************************************/
19
20 struct RuntimeHash * noargallocateRuntimeHash();
21 struct RuntimeHash * allocateRuntimeHash(int size);
22 void RuntimeHashaddChild(struct RuntimeHash *thisvar, struct RuntimeHash * child);
23 void freeRuntimeHash(struct RuntimeHash *);
24
25
26 int RuntimeHashadd(struct RuntimeHash *, int key, int data);
27 int RuntimeHashremove(struct RuntimeHash *,int key, int data);
28 bool RuntimeHashcontainskey(struct RuntimeHash *,int key);
29 bool RuntimeHashcontainskeydata(struct RuntimeHash *,int key, int data);
30 int RuntimeHashget(struct RuntimeHash *,int key, int* data);
31 int RuntimeHashcountdata(struct RuntimeHash *,int data);
32 void RuntimeHashaddParent(struct RuntimeHash *,struct RuntimeHash* parent);
33 int RuntimeHashfirstkey(struct RuntimeHash *);
34 struct RuntimeIterator* RuntimeHashcreateiterator(struct RuntimeHash *);
35 void RuntimeHashiterator(struct RuntimeHash *, struct RuntimeIterator * it);
36 int RuntimeHashcount(struct RuntimeHash *, int key);
37 void RuntimeHashaddAll(struct RuntimeHash *, struct RuntimeHash * set);
38 struct RuntimeHash * RuntimeHashimageSet(struct RuntimeHash *, int key);
39
40 struct RuntimeHash {
41     int numelements;
42     int size;
43     struct RuntimeNode **bucket;
44     struct ArrayRuntime *listhead;
45     struct ArrayRuntime *listtail;
46     int tailindex;
47 };
48
49 inline int RuntimeHashcountset(struct RuntimeHash * thisvar);
50
51 /* RuntimeHashException  *************************************************/
52
53
54 /* RuntimeIterator *****************************************************/
55 #define ARRAYSIZE 100
56
57 struct RuntimeNode {
58   struct RuntimeNode *next;
59   int data;
60   int key;
61   int inuse;
62 };
63
64 struct ArrayRuntime {
65   struct RuntimeNode nodes[ARRAYSIZE];
66   struct ArrayRuntime * nextarray;
67 };
68
69
70 struct RuntimeIterator {
71   struct ArrayRuntime *cur, *tail;
72   int index,tailindex;
73 };
74
75 inline struct RuntimeIterator * noargallocateRuntimeIterator();
76
77 inline struct RuntimeIterator * allocateRuntimeIterator(struct ArrayRuntime *start, struct ArrayRuntime *tl, int tlindex);
78
79 inline int RunhasNext(struct RuntimeIterator *thisvar);
80
81 inline int Runnext(struct RuntimeIterator *thisvar);
82
83 inline int Runkey(struct RuntimeIterator *thisvar);
84
85 #endif