After merging with master branch ...
[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->graph = NULL;
15         return This;
16 }
17
18 void initializeOrderHashTable(Order *This) {
19         This->orderPairTable = allocHashTableOrderPair(HT_INITIAL_CAPACITY, HT_DEFAULT_FACTOR);
20 }
21
22 void addOrderConstraint(Order *This, BooleanOrder *constraint) {
23         pushVectorBooleanOrder( &This->constraints, constraint);
24 }
25
26 void setOrderEncodingType(Order *This, OrderEncodingType type) {
27         This->order.type = type;
28 }
29
30 void deleteOrder(Order *This) {
31         deleteVectorArrayBooleanOrder(&This->constraints);
32         deleteOrderEncoding(&This->order);
33         if (This->orderPairTable != NULL) {
34                 resetAndDeleteHashTableOrderPair(This->orderPairTable);
35                 deleteHashTableOrderPair(This->orderPairTable);
36         }
37         if (This->graph != NULL) {
38                 deleteOrderGraph(This->graph);
39         }
40         ourfree(This);
41 }