Generated on Wed Jan 4 17:49:08 2006 for Gecode by doxygen 1.4.6

eq.icc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Christian Schulte <schulte@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Christian Schulte, 2004
00007  *
00008  *  Last modified:
00009  *     $Date: 2005-11-01 14:52:02 +0100 (Tue, 01 Nov 2005) $ by $Author: schulte $
00010  *     $Revision: 2462 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
00019  *
00020  */
00021 
00022 namespace Gecode { namespace Int { namespace Bool {
00023 
00024   template<class BVA, class BVB>
00025   forceinline
00026   Eq<BVA,BVB>::Eq(Space* home, BVA b0, BVB b1)
00027     : BoolBinary<BVA,BVB>(home,b0,b1) {}
00028 
00029   template<class BVA, class BVB>
00030   forceinline ExecStatus
00031   Eq<BVA,BVB>::post(Space* home, BVA b0, BVB b1) {
00032     switch (bool_test(b0,b1)) {
00033     case BT_SAME: return ES_OK;
00034     case BT_COMP: return ES_FAILED;
00035     case BT_NONE:
00036       if (b0.zero()) {
00037         GECODE_ME_CHECK(b1.t_zero(home));
00038       } else if (b0.one()) {
00039         GECODE_ME_CHECK(b1.t_one(home));
00040       } else if (b1.zero()) {
00041         GECODE_ME_CHECK(b0.t_zero(home));
00042       } else if (b1.one()) {
00043         GECODE_ME_CHECK(b0.t_one(home));
00044       } else {
00045         (void) new (home) Eq<BVA,BVB>(home,b0,b1);
00046       }
00047     }
00048     return ES_OK;
00049   }
00050 
00051   template<class BVA, class BVB>
00052   forceinline
00053   Eq<BVA,BVB>::Eq(Space* home, bool share, Eq<BVA,BVB>& p) 
00054     : BoolBinary<BVA,BVB>(home,share,p) {}
00055 
00056   template<class BVA, class BVB>
00057   Actor*
00058   Eq<BVA,BVB>::copy(Space* home, bool share) {
00059     return new (home) Eq<BVA,BVB>(home,share,*this);
00060   }
00061 
00062   template<class BVA, class BVB>
00063   ExecStatus
00064   Eq<BVA,BVB>::propagate(Space* home) {
00065     if (x0.zero()) {
00066       GECODE_ME_CHECK(x1.t_zero(home));
00067     } else if (x0.one()) {
00068       GECODE_ME_CHECK(x1.t_one(home));
00069     } else if (x1.zero()) {
00070       x0.t_zero_none(home);
00071     } else {
00072       assert(x1.one());
00073       x0.t_one_none(home);
00074     }
00075     return ES_SUBSUMED;
00076   }
00077 
00078 }}}
00079 
00080 // STATISTICS: int-prop
00081