#ifndef SIMPLEHASH_H
#define SIMPLEHASH_H
-#ifndef bool
-#define bool int
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
-
+/* LinkedHashNode *****************************************************/
-#include <stdarg.h>
-#include <stdlib.h>
+class LinkedHashNode {
+
+public:
+ LinkedHashNode *next;
+ LinkedHashNode *lnext,*lprev;
+ int data;
+ int key;
-/* LinkedHashNode *****************************************************/
-struct LinkedHashNode * allocateLinkedHashNode(int key, int data, struct LinkedHashNode *next);
-struct LinkedHashNode * noargallocateLinkedHashNode();
+ LinkedHashNode(int key, int data, LinkedHashNode *next);
+ LinkedHashNode();
-struct LinkedHashNode {
- struct LinkedHashNode *next;
- struct LinkedHashNode *lnext,*lprev;
- int data;
- int key;
};
/* SimpleList *********************************************************/
-struct SimpleList * allocateSimpleList();
-void SimpleListadd(struct SimpleList *, int data);
-int SimpleListcontains(struct SimpleList *,int data);
-void SimpleListreset(struct SimpleList *);
-int SimpleListhasMoreElements(struct SimpleList *);
-int SimpleListnextElement(struct SimpleList *);
-
-struct SimpleList {
- struct LinkedHashNode head;
- struct LinkedHashNode *ptr;
+class SimpleList {
+private:
+ LinkedHashNode head;
+ LinkedHashNode *ptr;
+public:
+ SimpleList();
+ void add(int data);
+ int contains(int data);
+ void reset();
+ int hasMoreElements();
+ int nextElement();
};
/* WorkList *********************************************************/
#define WLISTSIZE 4*100
-struct WorkList * allocateWorkList();
-void freeWorkList(struct WorkList *);
-void WorkListreset(struct WorkList *);
-void WorkListadd(struct WorkList *,int id, int type, int lvalue, int rvalue);
-int WorkListhasMoreElements(struct WorkList *);
-int WorkListgetid(struct WorkList *);
-int WorkListgettype(struct WorkList *);
-int WorkListgetlvalue(struct WorkList *);
-int WorkListgetrvalue(struct WorkList *);
-void WorkListpop(struct WorkList *);
-
-
-struct WorkList {
+class WorkList {
+private:
struct ListNode *head;
struct ListNode *tail;
int headoffset;
int tailoffset;
+
+public:
+ WorkList();
+ ~WorkList();
+ void reset();
+ void add(int id, int type, int lvalue, int rvalue);
+ int hasMoreElements();
+ int getid();
+ int gettype();
+ int getlvalue();
+ int getrvalue();
+ void pop();
};
struct ListNode {
int data[WLISTSIZE];
- struct ListNode *next;
+ ListNode *next;
};
-
/* SimpleHash *********************************************************/
+class SimpleIterator;
-struct SimpleHash * noargallocateSimpleHash();
-struct SimpleHash * allocateSimpleHash(int size);
-void SimpleHashaddChild(struct SimpleHash *thisvar, struct SimpleHash * child);
-void freeSimpleHash(struct SimpleHash *);
-
-
-int SimpleHashadd(struct SimpleHash *, int key, int data);
-int SimpleHashremove(struct SimpleHash *,int key, int data);
-bool SimpleHashcontainskey(struct SimpleHash *,int key);
-bool SimpleHashcontainskeydata(struct SimpleHash *,int key, int data);
-int SimpleHashget(struct SimpleHash *,int key, int* data);
-int SimpleHashcountdata(struct SimpleHash *,int data);
-void SimpleHashaddParent(struct SimpleHash *,struct SimpleHash* parent);
-int SimpleHashfirstkey(struct SimpleHash *);
-struct SimpleIterator* SimpleHashcreateiterator(struct SimpleHash *, struct SimpleHash *);
-void SimpleHashiterator(struct SimpleHash *, struct SimpleIterator * it);
-int SimpleHashcount(struct SimpleHash *, int key);
-void SimpleHashaddAll(struct SimpleHash *, struct SimpleHash * set);
-struct SimpleHash * SimpleHashimageSet(struct SimpleHash *, int key);
-
-struct SimpleHash {
+class SimpleHash {
+private:
int numelements;
int size;
struct SimpleNode **bucket;
struct ArraySimple *listhead;
struct ArraySimple *listtail;
+
+
int numparents;
int numchildren;
- struct SimpleHash* parents[10];
- struct SimpleHash* children[10];
+ SimpleHash* parents[10];
+ SimpleHash* children[10];
+ void addChild(SimpleHash* child);
+public:
int tailindex;
+ SimpleHash(int size=100);
+ ~SimpleHash();
+ int add(int key, int data);
+ int remove(int key, int data);
+ bool contains(int key);
+ bool contains(int key, int data);
+ int get(int key, int& data);
+ int countdata(int data);
+ void addParent(SimpleHash* parent);
+ int firstkey();
+ SimpleIterator* iterator();
+ void iterator(SimpleIterator & it);
+ inline int count() {
+ return numelements;
+ }
+ int count(int key);
+ void addAll(SimpleHash * set);
+ SimpleHash * imageSet(int key);
};
-inline int count(struct SimpleHash * thisvar) {
- return thisvar->numelements;
-}
-
-
/* SimpleHashExcepion *************************************************/
struct SimpleNode {
struct SimpleNode *next;
int data;
- int key;
+ int key;
int inuse;
};
};
-struct SimpleIterator {
+class SimpleIterator {
+ public:
+
struct ArraySimple *cur, *tail;
int index,tailindex;
-};
-
-inline struct SimpleIterator * noargallocateSimpleIterator() {
- return (struct SimpleIterator*)malloc(sizeof(struct SimpleIterator));
-}
-
-inline struct SimpleIterator * allocateSimpleIterator(struct ArraySimple *start, struct ArraySimple *tl, int tlindex) {
- struct SimpleIterator *thisvar=(struct SimpleIterator*)malloc(sizeof(struct SimpleIterator));
- thisvar->cur = start;
- thisvar->index=0;
- thisvar->tailindex=tlindex;
- thisvar->tail=tl;
- return thisvar;
-}
-
-inline int hasNext(struct SimpleIterator *thisvar) {
- if (thisvar->cur==thisvar->tail &&
- thisvar->index==thisvar->tailindex)
- return 0;
- while((thisvar->index==ARRAYSIZE)||!thisvar->cur->nodes[thisvar->index].inuse) {
- if (thisvar->index==ARRAYSIZE) {
- thisvar->index=0;
- thisvar->cur=thisvar->cur->nextarray;
- } else
- thisvar->index++;
+ // SimpleHash * table;
+ inline SimpleIterator() {}
+
+ inline SimpleIterator(struct ArraySimple *start, struct ArraySimple *tl, int tlindex/*, SimpleHash *t*/) {
+ cur = start;
+ // table=t;
+ index=0;
+ tailindex=tlindex;
+ tail=tl;
+ }
+
+ inline int hasNext() {
+ if (cur==tail &&
+ index==tailindex)
+ return 0;
+ while((index==ARRAYSIZE)||!cur->nodes[index].inuse) {
+ if (index==ARRAYSIZE) {
+ index=0;
+ cur=cur->nextarray;
+ } else
+ index++;
}
- if (thisvar->cur->nodes[thisvar->index].inuse)
- return 1;
+ if (cur->nodes[index].inuse)
+ return 1;
else
- return 0;
-}
-
-inline int next(struct SimpleIterator *thisvar) {
- return thisvar->cur->nodes[thisvar->index++].data;
-}
-
-inline int key(struct SimpleIterator *thisvar) {
- return thisvar->cur->nodes[thisvar->index].key;
-}
+ return 0;
+ }
+
+ inline int next() {
+ return cur->nodes[index++].data;
+ }
+
+ inline int key() {
+ return cur->nodes[index].key;
+ }
+};
+/* SimpleHashExcepion *************************************************/
-struct RepairHashNode * allocateRepairHashNode(int setrelation, int rule, int lvalue, int rvalue, int data, int data2,int ismodify);
+class SimpleHashException {
+public:
+ SimpleHashException();
+};
-struct RepairHashNode {
- struct RepairHashNode *next;
- struct RepairHashNode *lnext;
+class RepairHashNode {
+ public:
+ RepairHashNode *next;
+ RepairHashNode *lnext;
int data;
int data2;
- int setrelation;
- int lvalue;
- int rvalue;
+ int setrelation;
+ int lvalue;
+ int rvalue;
int rule;
int ismodify;
+ RepairHashNode(int setrelation, int rule, int lvalue, int rvalue, int data, int data2,int ismodify);
};
-struct RepairHash * noargallocateRepairHash();
-struct RepairHash * allocateRepairHash(int size);
-void freeRepairHash(struct RepairHash *);
-int addset(struct RepairHash *, int setv, int rule, int value, int data);
-int addrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data);
-int addrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue, int data, int data2);
-bool containsset(struct RepairHash *, int setv, int rule, int value);
-bool containsrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int getset(struct RepairHash *, int setv, int rule, int value);
-int getrelation(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int getrelation2(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-int ismodify(struct RepairHash *, int relation, int rule, int lvalue, int rvalue);
-
-struct RepairHash {
+class RepairHash {
+
+private:
int numelements;
int size;
- struct RepairHashNode **bucket;
- struct RepairHashNode *nodelist;
-
+ RepairHashNode **bucket;
+ RepairHashNode *nodelist;
+
+public:
+ RepairHash();
+ RepairHash(int size);
+ ~RepairHash();
+ int addset(int setv, int rule, int value, int data);
+ int addrelation(int relation, int rule, int lvalue, int rvalue, int data);
+ int addrelation(int relation, int rule, int lvalue, int rvalue, int data, int data2);
+ bool containsset(int setv, int rule, int value);
+ bool containsrelation(int relation, int rule, int lvalue, int rvalue);
+ int getset(int setv, int rule, int value);
+ int getrelation(int relation, int rule, int lvalue, int rvalue);
+ int getrelation2(int relation, int rule, int lvalue, int rvalue);
+ int ismodify(int relation, int rule, int lvalue, int rvalue);
};
#endif
+
#ifndef TMAP_H
#define TMAP_H
#include "classlist.h"
-#include "redblack.h"
-#ifndef bool
-#define bool int
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
-
-struct typemap * allocatetypemap();
-void freetypemap(struct typemap *);
-void typemapreset(struct typemap *);
-void initializetypemapstack(struct typemap *, void *high);
-
-void typemapallocate(struct typemap *, void *, int);
-void typemapdeallocate(struct typemap *, void *);
-bool typemapassertvalidmemoryB(struct typemap *, void* low, void* high);
-bool typemapasserttypeB(struct typemap *, void *ptr, void *high, int structure);
-bool typemapassertvalidmemory(struct typemap *, void* low, int structure);
-bool typemapasserttype(struct typemap *, void *ptr, int structure);
-bool typemapistype(struct typemap *, void *ptr, void *high, int structure);
-bool typemapcheckmemory(struct typemap *, void* low, void* high);
-bool typemapchecktype(struct typemap *, bool doaction,void *ptr, int structure);
-bool typemapchecktypeB(struct typemap *, bool doaction, void *low, void *high,int structure, struct rbtree *ttree);
-int typemapfindoffsetstructure(struct typemap *, int s, int offset);
-
-
-struct typemap {
+class typemap {
+ public:
+ typemap(typeobject *);
+ ~typemap();
+ void allocate(void *, int);
+ void deallocate(void *);
+ bool assertvalidmemory(void* low, void* high);
+ bool asserttype(void *ptr, void *high, int structure);
+ bool assertvalidmemory(void* low, int structure);
+ bool asserttype(void *ptr, int structure);
+ bool istype(void *ptr, void *high, int structure);
+ void reset();
+ typeobject *size;
+ void initializestack(void *high);
+ private:
void *low;
void *high;
+ bool checkmemory(void* low, void* high);
+ bool checktype(bool doaction,void *ptr, int structure);
+ bool checktype(bool doaction, void *low, void *high,int structure, struct rbtree *ttree);
+ int findoffsetstructure(int s, int offset);
struct rbtree *alloctree;
struct rbtree *typetree;
};
-struct structuremap * allocatestructuremap(int s);
-void freestructuremap(struct structuremap *);
-
-struct structuremap {
+class structuremap {
+ public:
+ structuremap(int s);
+ ~structuremap();
int str;
struct rbtree *typetree;
};