Generated on Mon Nov 30 23:53:30 2009 for Gecode by doxygen 1.6.1

neg-bool.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2008
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-09-08 21:10:29 +0200 (Tue, 08 Sep 2009) $ by $Author: schulte $
00011  *     $Revision: 9692 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode {
00039 
00040   namespace Int {
00041 
00042     /*
00043      * Negated Boolean views
00044      *
00045      */
00046 
00047     /*
00048      * Constructors and initialization
00049      *
00050      */
00051     forceinline
00052     NegBoolView::NegBoolView(void) {}
00053     forceinline
00054     NegBoolView::NegBoolView(const BoolView& b)
00055       : DerivedViewBase<BoolView>(b) {}
00056     forceinline void
00057     NegBoolView::init(const BoolView& b) {
00058       view = b;
00059     }
00060 
00061 
00062     /*
00063      * Boolean domain tests
00064      *
00065      */
00066     forceinline BoolStatus
00067     NegBoolView::status(void) const {
00068       return view.status();
00069     }
00070     forceinline bool
00071     NegBoolView::zero(void) const {
00072       return view.one();
00073     }
00074     forceinline bool
00075     NegBoolView::one(void) const {
00076       return view.zero();
00077     }
00078     forceinline bool
00079     NegBoolView::none(void) const {
00080       return view.none();
00081     }
00082 
00083 
00084     /*
00085      * Boolean assignment operations
00086      *
00087      */
00088     forceinline ModEvent
00089     NegBoolView::zero_none(Space& home) {
00090       return view.one_none(home);
00091     }
00092     forceinline ModEvent
00093     NegBoolView::one_none(Space& home) {
00094       return view.zero_none(home);
00095     }
00096 
00097     forceinline ModEvent
00098     NegBoolView::zero(Space& home) {
00099       return view.one(home);
00100     }
00101     forceinline ModEvent
00102     NegBoolView::one(Space& home) {
00103       return view.zero(home);
00104     }
00105 
00106 
00107     /*
00108      * Value access
00109      *
00110      */
00111     forceinline int
00112     NegBoolView::min(void) const {
00113       return view.max();
00114     }
00115     forceinline int
00116     NegBoolView::max(void) const {
00117       return view.min();
00118     }
00119     forceinline int
00120     NegBoolView::val(void) const {
00121       return 1-view.val();
00122     }
00123 
00124 
00125     /*
00126      * Domain tests
00127      *
00128      */
00129     forceinline bool
00130     NegBoolView::assigned(void) const {
00131       return view.assigned();
00132     }
00133 
00134     /*
00135      * Propagator modification events
00136      *
00137      */
00138     forceinline void
00139     NegBoolView::schedule(Space& home, Propagator& p, ModEvent me) {
00140       return BoolView::schedule(home,p,me);
00141     }
00142     forceinline ModEvent
00143     NegBoolView::me(const ModEventDelta& med) {
00144       return BoolView::me(med);
00145     }
00146     forceinline ModEventDelta
00147     NegBoolView::med(ModEvent me) {
00148       return BoolView::med(me);
00149     }
00150 
00151 
00152     /*
00153      * Dependencies
00154      *
00155      */
00156     forceinline void
00157     NegBoolView::subscribe(Space& home, Propagator& p, PropCond pc,
00158                            bool process) {
00159       view.subscribe(home,p,pc,process);
00160     }
00161     forceinline void
00162     NegBoolView::cancel(Space& home, Propagator& p, PropCond pc) {
00163       view.cancel(home,p,pc);
00164     }
00165     forceinline void
00166     NegBoolView::subscribe(Space& home, Advisor& a) {
00167       view.subscribe(home,a);
00168     }
00169     forceinline void
00170     NegBoolView::cancel(Space& home, Advisor& a) {
00171       view.cancel(home,a);
00172     }
00173 
00174 
00175     /*
00176      * Delta information for advisors
00177      *
00178      */
00179     forceinline ModEvent
00180     NegBoolView::modevent(const Delta& d) {
00181       return BoolView::modevent(d);
00182     }
00183     forceinline int
00184     NegBoolView::min(const Delta& d) const {
00185       return view.max(d);
00186     }
00187     forceinline int
00188     NegBoolView::max(const Delta& d) const {
00189       return view.min(d);
00190     }
00191     forceinline bool
00192     NegBoolView::any(const Delta& d) const {
00193       return view.any(d);
00194     }
00195     forceinline bool
00196     NegBoolView::zero(const Delta& d) {
00197       return BoolView::one(d);
00198     }
00199     forceinline bool
00200     NegBoolView::one(const Delta& d) {
00201       return BoolView::zero(d);
00202     }
00203 
00204 
00205 
00206     /*
00207      * Cloning
00208      *
00209      */
00210     forceinline void
00211     NegBoolView::update(Space& home, bool share, NegBoolView& b) {
00212       view.update(home,share,b.view);
00213     }
00214 
00215 
00220     template<>
00221     class ViewRanges<NegBoolView> : public Iter::Ranges::Singleton {
00222     public:
00224 
00225 
00226       ViewRanges(void);
00228       ViewRanges(const NegBoolView& x);
00230       void init(const NegBoolView& x);
00232     };
00233 
00234     forceinline
00235     ViewRanges<NegBoolView>::ViewRanges(void) {}
00236 
00237     forceinline
00238     ViewRanges<NegBoolView>::ViewRanges(const NegBoolView& x)
00239       : Iter::Ranges::Singleton(x.min(),x.max()) {}
00240 
00241     forceinline void
00242     ViewRanges<NegBoolView>::init(const NegBoolView& x) {
00243       Iter::Ranges::Singleton::init(x.min(),x.max());
00244     }
00245 
00246   }
00247 
00248 
00249   /*
00250    * View comparison
00251    *
00252    */
00253   forceinline bool
00254   same(const Int::NegBoolView& x, const Int::NegBoolView& y) {
00255     return same(x.base(),y.base());
00256   }
00257   forceinline bool
00258   before(const Int::NegBoolView& x, const Int::NegBoolView& y) {
00259     return before(x.base(),y.base());
00260   }
00261 
00262 }
00263 
00264 // STATISTICS: int-var