/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Guido Tack * Christian Schulte * * Copyright: * Guido Tack, 2004,2005 * Christian Schulte, 2004,2005 * * Last modified: * $Date: 2008-05-27 19:24:07 +0200 (Tue, 27 May 2008) $ by $Author: tack $ * $Revision: 6982 $ * * 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. * */ namespace Gecode { namespace Set { namespace Element { template forceinline IdxView* IdxView::allocate(Space* home, int n) { return static_cast*>(home->alloc(sizeof(IdxView)*n)); } template IdxViewArray::IdxViewArray(void) : xs(NULL), n(0) {} template IdxViewArray::IdxViewArray(const IdxViewArray& a) { n = a.n; xs = a.xs; } template IdxViewArray::IdxViewArray(Space* home, const SetVarArgs& xa) : xs(NULL) { n = xa.size(); if (n>0) { xs = IdxView::allocate(home, n); for (int i = n; i--; ) { SetView xav(xa[i]); View xavv(xav); xs[i].idx = i; xs[i].var = xavv; } } } template forceinline int IdxViewArray::size(void) const { return n; } template forceinline void IdxViewArray::size(int n0) { n = n0; } template forceinline IdxView& IdxViewArray::operator[](int i) { assert((i >= 0) && (i < size())); return xs[i]; } template forceinline const IdxView& IdxViewArray::operator[](int i) const { assert((i >= 0) && (i < size())); return xs[i]; } template void IdxViewArray::subscribe(Space* home, Propagator* p, PropCond pc, bool process) { for (int i = n; i--; ) xs[i].var.subscribe(home,p,pc,process); } template void IdxViewArray::cancel(Space* home, Propagator* p, PropCond pc) { for (int i = n; i--; ) xs[i].var.cancel(home,p,pc); } template void IdxViewArray::update(Space* home, bool share, IdxViewArray& a) { n = a.size(); if (n>0) { xs = IdxView::allocate(home,n); for (int i=n; i--; ) { xs[i].idx = a[i].idx; xs[i].var.update(home,share,a[i].var); } } } template Reflection::Arg* IdxViewArray::spec(const Space* home, Reflection::VarMap& m) const { Reflection::IntArrayArg* is = Reflection::Arg::newIntArray(n); for (int i = 0; i IdxViewArray::IdxViewArray(Space* home, const Reflection::VarMap& vars, Reflection::Arg* spec) : xs(NULL) { Reflection::IntArrayArg* is = spec->first()->toIntArray(); Reflection::ArrayArg* s = spec->second()->toArray(); n = is->size(); if (n>0) { xs = IdxView::allocate(home, n); for (int i = n; i--; ) { View xavv(home, vars, (*s)[i]); xs[i].idx = (*is)[i]; xs[i].var = xavv; } } } }}} // STATISTICS: set-prop