|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| LiteralsUtils.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 | package org.sat4j.minisat.core; | |
| 2 | ||
| 3 | /** | |
| 4 | * Utility methods to avoid using bit manipulation inside code. | |
| 5 | * One should use Java 1.5 import static feature to use it without | |
| 6 | * class qualification inside the code. | |
| 7 | * | |
| 8 | * In the DIMACS format, the literals are represented by signed integers, | |
| 9 | * 0 denoting the end of the clause. | |
| 10 | * In the solver, the literals are represented by positive integers, in | |
| 11 | * order to use them as index in arrays for instance. | |
| 12 | * <pre> | |
| 13 | * int p : a literal (p>1) | |
| 14 | * p ^ 1 : the negation of the literal | |
| 15 | * p >> 1 : the DIMACS number reresenting the variable. | |
| 16 | * int v : a DIMACS variable (v>0) | |
| 17 | * v << 1 : a positive literal for that variable in the solver. | |
| 18 | * v << 1 ^ 1 : a negative literal for that variable. | |
| 19 | * </pre> | |
| 20 | * @author leberre | |
| 21 | * | |
| 22 | */ | |
| 23 | public final class LiteralsUtils { | |
| 24 | ||
| 25 | 0 | private LiteralsUtils() { |
| 26 | // no instance supposed to be created. | |
| 27 | } | |
| 28 | ||
| 29 | 0 | public static int var(int p) { |
| 30 | assert p > 1; | |
| 31 | 0 | return p >> 1; |
| 32 | } | |
| 33 | ||
| 34 | 0 | public static int neg(int p) { |
| 35 | 0 | return p ^ 1; |
| 36 | } | |
| 37 | } |
|
||||||||||