1 #ifndef ELEMENTENCODING_H
2 #define ELEMENTENCODING_H
4 #include "naiveencoder.h"
5 #include "constraint.h"
7 enum ElementEncodingType {
8 ELEM_UNASSIGNED, ONEHOT, UNARY, BINARYINDEX, ONEHOTBINARY, BINARYVAL
11 typedef enum ElementEncodingType ElementEncodingType;
13 struct ElementEncoding {
14 ElementEncodingType type;
16 Edge * variables;/* List Variables Used To Encode Element */
19 uint64_t * encodingArray; /* List the Variables in the appropriate order */
20 uint64_t * inUseArray;/* Bitmap to track variables in use */
24 uint64_t offset;/* Value = offset + encoded number (interpretted according to isBinaryValSigned) */
25 uint64_t low;/* Lowest value to encode */
26 uint64_t high;/* High value to encode. If low > high, we assume wrap around to include 0. */
28 bool isBinaryValSigned;
31 uint numVars; /* Number of variables */
34 void initElementEncoding(ElementEncoding *This, Element *element);
35 static inline ElementEncodingType getElementEncodingType(ElementEncoding * This) {return This->type;}
36 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type);
37 void deleteElementEncoding(ElementEncoding *This);
38 void allocEncodingArrayElement(ElementEncoding *This, uint size);
39 void allocInUseArrayElement(ElementEncoding *This, uint size);
40 static inline uint numEncodingVars(ElementEncoding *This) {return This->numVars;}
42 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
43 return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
46 static inline void setInUseElement(ElementEncoding *This, uint offset) {
47 This->inUseArray[(offset>>6)] |= 1 << (offset & 63);