/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Guido Tack * * Copyright: * Guido Tack, 2011 * * This file is part of Gecode, the generic constraint * development environment: * http://www.gecode.org * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #include namespace Gecode { namespace Set { template forceinline CachedView::CachedView(void) {} template forceinline CachedView::CachedView(const View& y) : DerivedView(y) {} template forceinline unsigned int CachedView::glbSize(void) const { return x.glbSize(); } template forceinline unsigned int CachedView::lubSize(void) const { return x.lubSize(); } template forceinline unsigned int CachedView::unknownSize(void) const { return x.unknownSize(); } template forceinline bool CachedView::contains(int n) const { return x.contains(n); } template forceinline bool CachedView::notContains(int n) const { return x.notContains(n); } template forceinline unsigned int CachedView::cardMin(void) const { return x.cardMin(); } template forceinline unsigned int CachedView::cardMax(void) const { return x.cardMax(); } template forceinline int CachedView::lubMin(void) const { return x.lubMin(); } template forceinline int CachedView::lubMax(void) const { return x.lubMax(); } template forceinline int CachedView::glbMin(void) const { return x.glbMin(); } template forceinline int CachedView::glbMax(void) const { return x.glbMax(); } template forceinline ModEvent CachedView::cardMin(Space& home, unsigned int m) { return x.cardMin(home,m); } template forceinline ModEvent CachedView::cardMax(Space& home, unsigned int m) { return x.cardMax(home,m); } template forceinline ModEvent CachedView::include(Space& home, int i) { return x.include(home,i); } template forceinline ModEvent CachedView::exclude(Space& home, int i) { return x.exclude(home,i); } template forceinline ModEvent CachedView::intersect(Space& home, int i) { return x.intersect(home,i); } template forceinline ModEvent CachedView::intersect(Space& home, int i, int j) { return x.intersect(home,i,j); } template forceinline ModEvent CachedView::include(Space& home, int i, int j) { return x.include(home,i,j); } template forceinline ModEvent CachedView::exclude(Space& home, int i, int j) { return x.exclude(home,i,j); } template template ModEvent CachedView::excludeI(Space& home,I& iter) { return x.excludeI(home,iter); } template template ModEvent CachedView::includeI(Space& home,I& iter) { return x.includeI(home,iter); } template template ModEvent CachedView::intersectI(Space& home,I& iter) { return x.intersectI(home,iter); } template forceinline void CachedView::subscribe(Space& home, Propagator& p, PropCond pc, bool schedule) { x.subscribe(home,p,pc,schedule); } template forceinline void CachedView::cancel(Space& home, Propagator& p, PropCond pc) { x.cancel(home,p,pc); } template forceinline void CachedView::subscribe(Space& home, Advisor& a) { x.subscribe(home,a); } template forceinline void CachedView::cancel(Space& home, Advisor& a) { x.cancel(home,a); } template forceinline void CachedView::schedule(Space& home, Propagator& p, ModEvent me) { return View::schedule(home,p,me); } template forceinline ModEvent CachedView::me(const ModEventDelta& med) { return View::me(med); } template forceinline ModEventDelta CachedView::med(ModEvent me) { return View::med(me); } /* * Delta information for advisors * */ template forceinline ModEvent CachedView::modevent(const Delta& d) { return View::modevent(d); } template forceinline int CachedView::glbMin(const Delta& d) const { return x.glbMin(d); } template forceinline int CachedView::glbMax(const Delta& d) const { return x.glbMax(d); } template forceinline bool CachedView::glbAny(const Delta& d) const { return x.glbAny(d); } template forceinline int CachedView::lubMin(const Delta& d) const { return x.lubMin(d); } template forceinline int CachedView::lubMax(const Delta& d) const { return x.lubMax(d); } template forceinline bool CachedView::lubAny(const Delta& d) const { return x.lubAny(d); } template forceinline void CachedView::update(Space& home, CachedView& y) { lubCache.update(home,y.lubCache); glbCache.update(home,y.glbCache); DerivedView::update(home,y); } /* * Cache operations * */ template void CachedView::initCache(Space& home, const IntSet& glb, const IntSet& lub) { glbCache.init(home); IntSetRanges gr(glb); glbCache.includeI(home,gr); lubCache.init(home); IntSetRanges lr(lub); lubCache.intersectI(home,lr); } template forceinline void CachedView::cacheGlb(Space& home) { GlbRanges gr(DerivedView::base()); glbCache.includeI(home,gr); } template forceinline void CachedView::cacheLub(Space& home) { LubRanges lr(DerivedView::base()); lubCache.intersectI(home,lr); } template forceinline bool CachedView::glbModified(void) const { return glbCache.size() != glbSize(); } template forceinline bool CachedView::lubModified(void) const { return lubCache.size() != lubSize(); } /** * \brief %Range iterator for least upper bound of cached set views * \ingroup TaskActorSetView */ template class LubRanges > : public LubRanges { public: /// \name Constructors and initialization //@{ /// Default constructor LubRanges(void) {} /// Initialize with ranges for view \a x LubRanges(const CachedView& x); /// Initialize with ranges for view \a x void init(const CachedView& x); //@} }; template forceinline LubRanges >::LubRanges(const CachedView& s) : LubRanges(s.base()) {} template forceinline void LubRanges >::init(const CachedView& s) { LubRanges::init(s.base()); } /** * \brief %Range iterator for greatest lower bound of cached set views * \ingroup TaskActorSetView */ template class GlbRanges > : public GlbRanges { public: /// \name Constructors and initialization //@{ /// Default constructor GlbRanges(void) {} /// Initialize with ranges for view \a x GlbRanges(const CachedView & x); /// Initialize with ranges for view \a x void init(const CachedView & x); //@} }; template forceinline GlbRanges >::GlbRanges(const CachedView & s) : GlbRanges(s.base()) {} template forceinline void GlbRanges >::init(const CachedView & s) { GlbRanges::init(s.base()); } template std::basic_ostream& operator <<(std::basic_ostream& os, const CachedView& x) { return os << x.base(); } template forceinline bool operator ==(const CachedView& x, const CachedView& y) { return x.base() == y.base(); } template forceinline bool operator !=(const CachedView& x, const CachedView& y) { return x.base() != y.base(); } template forceinline GlbDiffRanges::GlbDiffRanges(const CachedView& x) : gr(x.base()), cr(x.glbCache) { Iter::Ranges::Diff,BndSetRanges>::init(gr,cr); } template forceinline LubDiffRanges::LubDiffRanges(const CachedView& x) : cr(x.lubCache), lr(x.base()) { Iter::Ranges::Diff >::init(cr,lr); } }} // STATISTICS: set-var