Generated on Thu Mar 22 10:39:42 2012 for Gecode by doxygen 1.6.3

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: 2010-06-29 10:39:13 +0200 (Tue, 29 Jun 2010) $ by $Author: schulte $
00011  *     $Revision: 11118 $
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 { namespace Int {
00039 
00040   /*
00041    * Negated Boolean views
00042    *
00043    */
00044 
00045   /*
00046    * Constructors and initialization
00047    *
00048    */
00049   forceinline
00050   NegBoolView::NegBoolView(void) {}
00051   forceinline
00052   NegBoolView::NegBoolView(const BoolView& y)
00053     : DerivedView<BoolView>(y) {}
00054 
00055 
00056   /*
00057    * Boolean domain tests
00058    *
00059    */
00060   forceinline BoolStatus
00061   NegBoolView::status(void) const {
00062     return x.status();
00063   }
00064   forceinline bool
00065   NegBoolView::zero(void) const {
00066     return x.one();
00067   }
00068   forceinline bool
00069   NegBoolView::one(void) const {
00070     return x.zero();
00071   }
00072   forceinline bool
00073   NegBoolView::none(void) const {
00074     return x.none();
00075   }
00076 
00077 
00078   /*
00079    * Boolean assignment operations
00080    *
00081    */
00082   forceinline ModEvent
00083   NegBoolView::zero_none(Space& home) {
00084     return x.one_none(home);
00085   }
00086   forceinline ModEvent
00087   NegBoolView::one_none(Space& home) {
00088     return x.zero_none(home);
00089   }
00090 
00091   forceinline ModEvent
00092   NegBoolView::zero(Space& home) {
00093     return x.one(home);
00094   }
00095   forceinline ModEvent
00096   NegBoolView::one(Space& home) {
00097     return x.zero(home);
00098   }
00099 
00100 
00101   /*
00102    * Value access
00103    *
00104    */
00105   forceinline int
00106   NegBoolView::min(void) const {
00107     return x.max();
00108   }
00109   forceinline int
00110   NegBoolView::max(void) const {
00111     return x.min();
00112   }
00113   forceinline int
00114   NegBoolView::val(void) const {
00115     return 1-x.val();
00116   }
00117 
00118 
00119   /*
00120    * Delta information for advisors
00121    *
00122    */
00123   forceinline int
00124   NegBoolView::min(const Delta& d) const {
00125     return x.max(d);
00126   }
00127   forceinline int
00128   NegBoolView::max(const Delta& d) const {
00129     return x.min(d);
00130   }
00131   forceinline bool
00132   NegBoolView::any(const Delta& d) const {
00133     return x.any(d);
00134   }
00135   forceinline bool
00136   NegBoolView::zero(const Delta& d) {
00137     return BoolView::one(d);
00138   }
00139   forceinline bool
00140   NegBoolView::one(const Delta& d) {
00141     return BoolView::zero(d);
00142   }
00143 
00144 
00149   template<>
00150   class ViewRanges<NegBoolView> : public Iter::Ranges::Singleton {
00151   public:
00153 
00154 
00155     ViewRanges(void);
00157     ViewRanges(const NegBoolView& x);
00159     void init(const NegBoolView& x);
00161   };
00162 
00163   forceinline
00164   ViewRanges<NegBoolView>::ViewRanges(void) {}
00165 
00166   forceinline
00167   ViewRanges<NegBoolView>::ViewRanges(const NegBoolView& x)
00168     : Iter::Ranges::Singleton(x.min(),x.max()) {}
00169 
00170   forceinline void
00171   ViewRanges<NegBoolView>::init(const NegBoolView& x) {
00172     Iter::Ranges::Singleton::init(x.min(),x.max());
00173   }
00174 
00175 }}
00176 
00177 // STATISTICS: int-var