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 size = _intvars.size();
int value = event_var.value();
boolean bit = _bits.bit(value);
// check for failure
if (bit)
{
//Debug.on();Debug.print("diff fail: "+interest+_intvars+_bits);Debug.off();
var.constrainer().fail("AllDiff"); //+_bits +" "+_intvars);
}
// set the bit
_bits.bit(value,true); //Debug.on();Debug.print(" "+this+": "+_bits);Debug.off();
var.constrainer().addUndo(UndoBits.getUndo(_bits,value));
// additional propagation
IntExp[] data = _intvars.data();
for(int i=0; i < size; i++)
{
IntExp vari = data[i];
if (vari!=event_var)
{
//Debug.on();Debug.print("alldiff remove "+value+" from "+vari);Debug.off();
vari.removeValue(value); // may fail
}
}
}