package fr.lifl.stc.stan.implicitFlow.data;
import java.util.Vector;
/**
*
* @author dorina
*
*/
public class Minterm {
/**
* contains BooleanVariables ordered after line
*/
Vector terms;
/**
*
*
*/
public Minterm(){
terms = new Vector();
}
/**
*
* @param b
*/
public Minterm(BooleanVariable b){
this();
terms.add(b);
}
public Minterm(Minterm m) {
terms = new Vector();
for(int i=0; i < m.size(); i++){
this.terms.add(m.terms.elementAt(i));
}
}
/**
*
* @return
*/
public int size(){
return terms.size();
}
/**
*
* @return
*/
public boolean isTrue(){
if(size() != 1)
return false;
BooleanVariable b = terms.elementAt(0);
return b == BooleanVariable.condition_true;
}
/**
*
* @return
*/
public boolean isFalse(){
if(size() != 1)
return false;
BooleanVariable b = terms.elementAt(0);
return b == BooleanVariable.condition_false;
}
/**
*
*/
public boolean equals(Object obj){
if(!(obj instanceof Minterm))
return false;
Minterm m = (Minterm)obj;
if(this.size() != m.size())
return false;
for(int i=0; i < this.size(); i++){
if(! this.terms.elementAt(i).equals(m.terms.elementAt(i)))
return false;
}
return true;
}
/**
*
* @param m
* @return true
if this
is greater or equal than m
*/
public boolean greaterOrEqualTo(Minterm m){
if(this.size() line && i <= size());
i--;
terms.add(i, b);
*/
}
public void insertOnTop(BooleanVariable b){
this.terms.add(0, b);
}
/**
*
* @param b
*/
private void delete(BooleanVariable b){
terms.removeElement(b);
if(terms.size() == 0)
terms.add(BooleanVariable.condition_true);
}
public boolean contains(BooleanVariable b){
return this.terms.contains(b);
}
public String toString(){
String s = "[ ";//size = "+this.terms.size()+" ";
for(int i = 0; i < terms.size(); i++) {
s += terms.elementAt(i);
if( i < terms.size()-1)
s += "&";
}
s += "]";
return s;
}
}