#include "orderpair.h"
-OrderPair *allocOrderPair(uint64_t first, uint64_t second, Edge constraint) {
- OrderPair *pair = (OrderPair *) ourmalloc(sizeof(OrderPair));
- pair->first = first;
- pair->second = second;
- pair->constraint = constraint;
- return pair;
+OrderPair::OrderPair(uint64_t _first, uint64_t _second, Edge _constraint) :
+ first(_first),
+ second(_second),
+ constraint(_constraint) {
}
-void deleteOrderPair(OrderPair *pair) {
- ourfree(pair);
+OrderPair::OrderPair() :
+ first(0),
+ second(0),
+ constraint(E_NULL) {
}
Edge constraint;
if (!(table->contains(pair))) {
constraint = getNewVarSATEncoder(This);
- OrderPair *paircopy = allocOrderPair(pair->first, pair->second, constraint);
+ OrderPair *paircopy = new OrderPair(pair->first, pair->second, constraint);
table->put(paircopy, paircopy);
} else
constraint = table->get(pair)->constraint;
}
createAllTotalOrderConstraintsSATEncoder(This, boolOrder->order);
}
- OrderPair pair = {boolOrder->first, boolOrder->second, E_NULL};
+ OrderPair pair(boolOrder->first, boolOrder->second, E_NULL);
Edge constraint = getPairConstraint(This, boolOrder->order, &pair);
return constraint;
}
uint64_t valueI = mems->get(i);
for (uint j = i + 1; j < size; j++) {
uint64_t valueJ = mems->get(j);
- OrderPair pairIJ = {valueI, valueJ};
+ OrderPair pairIJ(valueI, valueJ, E_NULL);
Edge constIJ = getPairConstraint(This, order, &pairIJ);
for (uint k = j + 1; k < size; k++) {
uint64_t valueK = mems->get(k);
- OrderPair pairJK = {valueJ, valueK};
- OrderPair pairIK = {valueI, valueK};
+ OrderPair pairJK(valueJ, valueK, E_NULL);
+ OrderPair pairIK(valueI, valueK, E_NULL);
Edge constIK = getPairConstraint(This, order, &pairIK);
Edge constJK = getPairConstraint(This, order, &pairJK);
addConstraintCNF(This->cnf, generateTransOrderConstraintSATEncoder(This, constIJ, constJK, constIK));
HappenedBefore getOrderConstraintValueSATTranslator(CSolver *This, Order *order, uint64_t first, uint64_t second) {
ASSERT(order->orderPairTable != NULL);
- OrderPair pair = {first, second, E_NULL};
+ OrderPair pair(first, second, E_NULL);
Edge var = getOrderConstraint(order->orderPairTable, &pair);
if (edgeIsNull(var))
return UNORDERED;