1499dcb16be20425d260c1f9db2b1341a08055f7
[satune.git] / src / AST / order.c
1 #include "order.h"
2 #include "structs.h"
3 #include "set.h"
4 #include "boolean.h"
5
6 Order* allocOrder(OrderType type, Set * set){
7         Order* This = (Order*)ourmalloc(sizeof(Order));
8         This->set=set;
9         initDefVectorBoolean(& This->constraints);
10         This->type=type;
11         initOrderEncoding(& This->order, This);
12         This->boolsToConstraints = NULL;
13         return This;
14 }
15
16 void initializeOrderHashTable(Order* This){
17         This->boolsToConstraints= allocHashTableBoolConst(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
18 }
19
20 void addOrderConstraint(Order* This, BooleanOrder* constraint){
21         pushVectorBoolean( &This->constraints, (Boolean*) constraint);
22 }
23
24 void setOrderEncodingType(Order* This, OrderEncodingType type){
25         This->order.type = type;
26 }
27
28 void deleteOrder(Order* This){
29         deleteVectorArrayBoolean(& This->constraints);
30         deleteOrderEncoding(& This->order);
31         if(This->boolsToConstraints!= NULL) {
32                 resetAndDeleteHashTableBoolConst(This->boolsToConstraints);
33                 deleteHashTableBoolConst(This->boolsToConstraints);
34         }
35         ourfree(This);
36 }