/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/*
* File: set.h
* Author: hamed
*
#ifndef SET_H
#define SET_H
-#include "types.h"
+#include "classlist.h"
+#include "structs.h"
+#include "mymemory.h"
-enum Comparison{LESS, EQUAL, GREATER};
-
-class Node{
-private:
- bool range;
- // If it isn't a range, begin contains the actual value of the element
- uint64 beginOrVal;
- uint64 end;
- Node* right;
- Node* left;
-public:
- Node(uint64 val, Node* r, Node* l);
- Node(uint64 val);
- Node(uint64 begin, uint64 end, Node* r, Node* l);
- Node(uint64 begin, uint64 end);
- bool isRange(){return range;}
- uint64 getBeginOrRange(){return beginOrVal;}
- Comparison compare(uint64 val);
- /**
- * Searches the tree, if new node exists in the tree ( whether its value
- * is in range of another node, or there is another node with the value of
- * node n) this function just returns!
- * @param n
- */
- void addNode(Node* n);
+struct Set {
+ VarType type;
+ bool isRange;
+ uint64_t low, high;
+ VectorInt * members;
};
-// For now, we can consider it as a simple binary tree, but we can have fancier
-// trees for future
-class Set{
- Type type;
- uint64 size;
- Node* root;
- Set(Type t, uint64 * elements, int num);
- Set(Type t, uint64 lowrange, uint64 highrange);
- Set(Type t);
- /**
- * For know all sets are considered to be mutable, we can change it later on
- * if it was necessary.
- * @param set
- * @param element
- */
- void addItem(uint64 element);
- ELEMENT* createUniqueItem(Set * set);
-};
+Set *allocSet(VarType t, uint64_t * elements, uint num);
+Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange);
+void freeSet(Set *set);
-#endif /* SET_H */
+#endif/* SET_H */