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