added some comments

This commit is contained in:
hneemann 2016-05-04 23:20:06 +02:00
parent ba4df394cb
commit b5a152d83a
7 changed files with 78 additions and 1 deletions

View File

@ -12,6 +12,11 @@ public class ComplexityInclNotVisitor implements ExpressionVisitor {
return true; return true;
} }
/**
* Returns a measure for the complexity of the examined expression
*
* @return the complexity
*/
public int getComplexity() { public int getComplexity() {
return counter; return counter;
} }

View File

@ -13,6 +13,12 @@ public class ComplexityVisitor implements ExpressionVisitor {
return true; return true;
} }
/**
* Returns a measure for the complexity of the examined expression
* The Not expression does not increase this complexity measure
*
* @return the complexity
*/
public int getComplexity() { public int getComplexity() {
return counter; return counter;
} }

View File

@ -9,10 +9,22 @@ public class Variable implements Comparable<Variable>, Expression {
private String identifier; private String identifier;
/**
* Creates a new Variable
*
* @param name the variables name
* @return the new Variable
*/
public static Variable v(String name) { public static Variable v(String name) {
return new Variable(name); return new Variable(name);
} }
/**
* Creates an array of variables
*
* @param n the number of varfiables to create.
* @return variables named "A0", "A1", "A2" and so on
*/
public static ArrayList<Variable> vars(int n) { public static ArrayList<Variable> vars(int n) {
ArrayList<Variable> v = new ArrayList<Variable>(); ArrayList<Variable> v = new ArrayList<Variable>();
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
@ -20,6 +32,12 @@ public class Variable implements Comparable<Variable>, Expression {
return v; return v;
} }
/**
* Create a list of variables using the given names
*
* @param names the names used to create the variables
* @return the list of variables
*/
public static ArrayList<Variable> vars(String... names) { public static ArrayList<Variable> vars(String... names) {
ArrayList<Variable> v = new ArrayList<Variable>(); ArrayList<Variable> v = new ArrayList<Variable>();
for (String n : names) for (String n : names)
@ -27,10 +45,16 @@ public class Variable implements Comparable<Variable>, Expression {
return v; return v;
} }
/**
* Creates a new intsnce
*
* @param identifier the variables name
*/
public Variable(String identifier) { public Variable(String identifier) {
this.identifier = identifier; this.identifier = identifier;
} }
@Override
public boolean calculate(Context context) throws ExpressionException { public boolean calculate(Context context) throws ExpressionException {
return context.get(this); return context.get(this);
} }
@ -46,6 +70,9 @@ public class Variable implements Comparable<Variable>, Expression {
return identifier; return identifier;
} }
/**
* @return the variables name
*/
public String getIdentifier() { public String getIdentifier() {
return identifier; return identifier;
} }

View File

@ -5,7 +5,7 @@ package de.neemann.digital.analyse.expression.format;
* *
* @author hneemann * @author hneemann
*/ */
public class FormatterException extends Throwable { public class FormatterException extends Exception {
/** /**
* Creates a new instance * Creates a new instance
* *

View File

@ -6,12 +6,20 @@ import de.neemann.digital.analyse.expression.Expression;
import de.neemann.digital.analyse.expression.ExpressionException; import de.neemann.digital.analyse.expression.ExpressionException;
/** /**
* Creates a bool table from the given expression
*
* @author hneemann * @author hneemann
*/ */
public class BoolTableExpression implements BoolTable { public class BoolTableExpression implements BoolTable {
private final Expression expression; private final Expression expression;
private final ContextFiller context; private final ContextFiller context;
/**
* Creates a new instance
*
* @param expression the expression
* @param context the context to evaluate the expression
*/
public BoolTableExpression(Expression expression, ContextFiller context) { public BoolTableExpression(Expression expression, ContextFiller context) {
this.expression = expression; this.expression = expression;
this.context = context; this.context = context;

View File

@ -6,7 +6,16 @@ package de.neemann.digital.analyse.quinemc;
* @author hneemann * @author hneemann
*/ */
public enum TableItem { public enum TableItem {
/**
* Zero of false
*/
zero, zero,
/**
* one or true
*/
one, one,
/**
* var is optimized
*/
optimized optimized
} }

View File

@ -4,11 +4,26 @@ package de.neemann.digital.analyse.quinemc;
* @author hneemann * @author hneemann
*/ */
public enum ThreeStateValue { public enum ThreeStateValue {
/**
* one or true
*/
one, one,
/**
* zero or false
*/
zero, zero,
/**
* dont care
*/
dontCare; dontCare;
/**
* Create a value from a bool
*
* @param bool the bool
* @return the created ThreeStateValue
*/
public static ThreeStateValue value(boolean bool) { public static ThreeStateValue value(boolean bool) {
if (bool) { if (bool) {
return one; return one;
@ -17,6 +32,13 @@ public enum ThreeStateValue {
} }
} }
/**
* Create a value from an int
* 0 and 1 work as expected, any other value means "dont care"
*
* @param value the value
* @return the created ThreeStateValue
*/
public static ThreeStateValue value(int value) { public static ThreeStateValue value(int value) {
switch (value) { switch (value) {
case 0: case 0: