class AllDiffObserver extends Observer
{
public void update(Subject var, EventOfInterest interest)
throws Failure
{
IntExp event_var = (IntExp)var;
//Debug.on(); Debug.print("AllDiffObserver("+var+") "+interest+" "+_bits); Debug.off();
int value = event_var.value();
// check for failure
if (!_bit_var.contains(value))
{
//Debug.on();Debug.print("diff fail: "+interest+_intvars+_bits);Debug.off();
var.constrainer().fail("AllDiff"); //+_bits +" "+_intvars);
}
// set the bit
int size = _intvars.size();
_bit_var.removeValue(value); //Debug.on();Debug.print(" "+this+": "+_bits);Debug.off();
// additional propagation
for(int i=0; i<size; i++)
{
IntExp vari = (IntExp)_intvars.elementAt(i);
if (vari != event_var)
{
//Debug.on();Debug.print("alldiff remove "+value+" from "+vari);Debug.off();
vari.removeValue(value); // may fail
}
}
}