Add LTE function for completeness and fix bug in LT
[satune.git] / src / AST / order.c
1 #include "order.h"
2 #include "structs.h"
3 #include "set.h"
4 #include "boolean.h"
5 #include "ordergraph.h"
6
7 Order *allocOrder(OrderType type, Set *set) {
8         Order *This = (Order *)ourmalloc(sizeof(Order));
9         This->set = set;
10         initDefVectorBooleanOrder(&This->constraints);
11         This->type = type;
12         initOrderEncoding(&This->order, This);
13         This->orderPairTable = NULL;
14         This->elementTable = NULL;
15         This->graph = NULL;
16         return This;
17 }
18
19 void initializeOrderHashTable(Order *This) {
20         This->orderPairTable = allocHashTableOrderPair(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
21 }
22
23 void initializeOrderElementsHashTable(Order *This){
24         This->elementTable = allocHashSetOrderElement(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
25 }
26
27 void addOrderConstraint(Order *This, BooleanOrder *constraint) {
28         pushVectorBooleanOrder( &This->constraints, constraint);
29 }
30
31 void setOrderEncodingType(Order *This, OrderEncodingType type) {
32         This->order.type = type;
33 }
34
35 void deleteOrder(Order *This) {
36         deleteVectorArrayBooleanOrder(&This->constraints);
37         deleteOrderEncoding(&This->order);
38         if (This->orderPairTable != NULL) {
39                 resetAndDeleteHashTableOrderPair(This->orderPairTable);
40                 deleteHashTableOrderPair(This->orderPairTable);
41         }
42         if(This->elementTable != NULL){
43                 deleteHashSetOrderElement(This->elementTable);
44         }
45         if (This->graph != NULL) {
46                 deleteOrderGraph(This->graph);
47         }
48         ourfree(This);
49 }