[gecode-users] Determining equal set variables

Guido Tack tack at ps.uni-sb.de
Wed Jul 15 09:47:36 CEST 2009


Chris Mears wrote:
> I can check if two IntViews are ground and equal like this:
>
>  IntView &x = ...
>  IntView &y = ...
>  if (x.assigned() && y.assigned() && x.val() == y.val())
>    ...
>
> Can I do the same thing for sets?  There doesn't seem to be an
> equivalent to "val()" in the SetView class.

You'll have to use iterators:

GlbRanges<SetView> xr(x);
GlbRanges<SetView> yr(y);
if (x.assigned() && y.assigned() && Iter::Ranges::equal(xr,yr))
...

If this test is done very often and the sets are usually not equal,  
you can check the cardinalities first in order to speed things up a bit:

if (x.assigned() && y.assigned() && x.cardMin()==y.cardMin() &&  
Iter::Ranges::equal(xr,yr))
...

Cheers,
	Guido





More information about the gecode-users mailing list