add more comments
[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 void RuntimeHashrehash(struct RuntimeHash * thisvar);
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 void RuntimeHashaddParent(struct RuntimeHash *,struct RuntimeHash* parent);
32 int RuntimeHashfirstkey(struct RuntimeHash *);
33 struct RuntimeIterator* RuntimeHashcreateiterator(struct RuntimeHash *);
34 void RuntimeHashiterator(struct RuntimeHash *, struct RuntimeIterator * it);
35 int RuntimeHashcount(struct RuntimeHash *, int key);
36 struct RuntimeHash * RuntimeHashimageSet(struct RuntimeHash *, int key);
37
38 struct RuntimeHash {
39     int numelements;
40     int size;
41     struct RuntimeNode **bucket;
42     struct RuntimeNode *listhead;
43     struct RuntimeNode *listtail;
44 };
45
46 inline int RuntimeHashcountset(struct RuntimeHash * thisvar);
47
48 /* RuntimeHashException  *************************************************/
49
50
51 /* RuntimeIterator *****************************************************/
52 #define ARRAYSIZE 100
53
54 struct RuntimeNode {
55   struct RuntimeNode *next;
56   struct RuntimeNode *lnext;
57   struct RuntimeNode *lprev;
58   int data;
59   int key;
60 };
61
62 struct RuntimeIterator {
63   struct RuntimeNode *cur;
64 };
65
66 inline struct RuntimeIterator * noargallocateRuntimeIterator();
67
68 inline struct RuntimeIterator * allocateRuntimeIterator(struct RuntimeNode *start);
69
70 inline int RunhasNext(struct RuntimeIterator *thisvar);
71
72 inline int Runnext(struct RuntimeIterator *thisvar);
73
74 inline int Runkey(struct RuntimeIterator *thisvar);
75
76 #endif