Convert HashSet
[satune.git] / src / set.c
1 #include "set.h"
2 #include <stddef.h>
3
4 Set * allocSet(VarType t, uint64_t* elements, uint num) {
5         Set * tmp=(Set *)ourmalloc(sizeof(struct Set));
6         tmp->type=t;
7         tmp->isRange=false;
8         tmp->low=0;
9         tmp->high=0;
10         tmp->members=allocVectorArrayInt(elements, num);
11         return tmp;
12 }
13
14 Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange) {
15         Set * tmp=(Set *)ourmalloc(sizeof(struct Set));
16         tmp->type=t;
17         tmp->isRange=true;
18         tmp->low=lowrange;
19         tmp->high=highrange;
20         tmp->members=NULL;
21         return tmp;
22 }
23
24 void freeSet(Set * set) {
25         if (set->isRange)
26                 freeVectorInt(set->members);
27         ourfree(set);
28 }