#include "cnfexpr.h"
-
+#include <stdio.h>
/*
V2 Copyright (c) 2014 Ben Chambers, Eugene Goldberg, Pete Manolios,
Vasilis Papavasileiou, Sudarshan Srinivasan, and Daron Vroon.
This->size = 0; //either true or false now depending on whether this is a conj or disj
return;
}
- if ((++This->size) >= This->capacity) {
- This->capacity <<= 1;
- This->literals=ourrealloc(This->literals, This->capacity * sizeof(Literal));
- }
-
- if (vec_size < MERGESIZE) {
- memmove(&This->literals[i+1], &This->literals[i], (vec_size-i) * sizeof(Literal));
- This->literals[i]=l;
- } else {
- This->literals[vec_size]=l;
- }
+ }
+ if ((++This->size) >= This->capacity) {
+ This->capacity <<= 1;
+ This->literals=ourrealloc(This->literals, This->capacity * sizeof(Literal));
+ }
+
+ if (vec_size < MERGESIZE) {
+ memmove(&This->literals[i+1], &This->literals[i], (vec_size-i) * sizeof(Literal));
+ This->literals[i]=l;
+ } else {
+ This->literals[vec_size]=l;
}
}
CNFExpr *This=ourmalloc(sizeof(CNFExpr));
This->litSize=0;
This->isTrue=isTrue;
- allocInlineVectorLitVector(&This->clauses, 2);
+ initVectorLitVector(&This->clauses, 2);
initLitVector(&This->singletons);
return This;
}
CNFExpr *This=ourmalloc(sizeof(CNFExpr));
This->litSize=1;
This->isTrue=false;
- allocInlineVectorLitVector(&This->clauses, 2);
+ initVectorLitVector(&This->clauses, 2);
initLitVector(&This->singletons);
addLiteralLitVector(&This->singletons, l);
return This;
deleteCNFExpr(expr);
}
-
-
+void printCNFExpr(CNFExpr *This) {
+ for(uint i=0;i<getSizeLitVector(&This->singletons);i++) {
+ if (i!=0)
+ printf(" ^ ");
+ Literal l=getLiteralLitVector(&This->singletons,i);
+ printf ("%d",l);
+ }
+ for(uint i=0;i<getSizeVectorLitVector(&This->clauses);i++) {
+ LitVector *lv=getVectorLitVector(&This->clauses,i);
+ printf(" ^ (");
+ for(uint j=0;j<getSizeLitVector(lv);j++) {
+ if (j!=0)
+ printf(" v ");
+ printf("%d", getLiteralLitVector(lv, j));
+ }
+ printf(")");
+ }
+}