Generated on Wed Nov 1 15:04:45 2006 for Gecode by doxygen 1.4.5

projector-set.cc

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-08-17 11:46:13 +0200 (Thu, 17 Aug 2006) $ by $Author: tack $
00010  *     $Revision: 3544 $
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 #include "gecode/set/projectors.hh"
00023 
00024 namespace Gecode {
00025 
00026   void
00027   ProjectorSet::add(const Projector& p) {
00028     _ps.ensure(_count+1);    
00029     new (&_ps[_count]) Projector(p);
00030     for (int i=_count+1; i<_ps.size(); i++)
00031       new (&_ps[i]) Projector();
00032     _count++;
00033 
00034     _arity = std::max(_arity, p.arity());
00035   }
00036 
00037   void
00038   ProjectorSet::scope(Support::DynamicArray<int>& s) const {
00039     // Clear out s
00040     for (int i=_arity+1; i--;)
00041       s[i] = Set::PC_SET_ANY + 1;
00042 
00043     // Collect scope from individual projectors
00044     for (int i=_count; i--; ) {
00045       _ps[i].scope(s);
00046     }
00047   }
00048 
00049   ExecStatus
00050   ProjectorSet::check(Space* home, ViewArray<Set::SetView>& x) {
00051     ExecStatus es = ES_SUBSUMED;
00052     for (int i=0; i<_count; i++) {
00053       ExecStatus es_new = _ps[i].check(home, x);
00054       switch (es_new) {
00055       case ES_FAILED:
00056         return ES_FAILED;
00057       case ES_SUBSUMED:
00058         break;
00059       default:
00060         es = es_new;
00061         break;
00062       }
00063     }
00064     return es;
00065   }
00066 
00067 }
00068 
00069 // STATISTICS: set-prop