import java.util.*;
import choco.integer.IntVar;
import choco.integer.var.IntDomainVar;
import choco.Problem;

public class IntVarCompare implements Comparator {

    public int compare(Object x,Object y){
	//System.out.println("compare: " + x + " " + y);
	IntVar X = (IntVar)x;
	IntVar Y = (IntVar)y;
	int i = X.getInf(),
	    j = Y.getInf();
        return (i - j);
    }

    public boolean equals(Object x){
	return equals(x);
    }


    public static void main(String[] args) {
	IntVarCompare c = new IntVarCompare();
	TreeSet    S = new TreeSet(c);
	Problem pb = new Problem();
	IntVar x = pb.makeBoundIntVar("x",3,5);
	IntVar y = pb.makeBoundIntVar("y",1,3);
	IntVar z = pb.makeBoundIntVar("z",2,4);
	IntVar yy = pb.makeBoundIntVar("yy",1,3);
	S.add(x);
	S.add(y);
	S.add(z);
	S.add(yy);

	System.out.println("size: " +  S.size() + " S = " + S);
	Iterator setIter = S.iterator();
	while (setIter.hasNext()) System.out.println(setIter.next());

	S.remove(z);
	System.out.println("size: " +  S.size() + " S = " + S);
	
    }
}
	    
