Main Page | Class Hierarchy | Class List | File List | Class Members

ConflictCounts.h

00001 // ConflictCounts.h -- The interface to a cache of conflict counts.
00002 
00003 /*
00004  * Copyright (C) 2004 Tudor Hulubei <tudor@hulubei.net>.
00005  *
00006  * This library is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as
00008  * published by the Free Software Foundation; either version 2, or (at
00009  * your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA,
00019  * 02111-1307, USA.
00020  */
00021 
00022 /*
00023  * NOTE: This is an interal header file.
00024  * You should not attempt to use it directly.
00025  */
00026 
00027 // $Id: ConflictCounts_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00028 
00029 #ifndef _CSP_CACHES_ConflictCounts_H
00030 #define _CSP_CACHES_ConflictCounts_H
00031 
00032 
00033 CSP_NAMESPACE_BEGIN(csp);
00034 CSP_NAMESPACE_BEGIN(caches);
00035 
00036 
00040 class CSP_API ConflictCounts
00041 {
00042   public:
00044     ConflictCounts(const Decomposition& decomposition) :
00045         m_decomposition(decomposition),
00046         m_variable(0) {}
00047 
00049     void init(const vlist_type& uninstantiatedVariables);
00050 
00059     void init(const Variable& variable, Domain& domain);
00060 
00062     void done();
00063 
00069     void setVariable(const Variable& variable)
00070     {
00071         m_variable = &variable;
00072     }
00073 
00081     size_t conflictCount(const Value& value) const;
00082 
00090     const hash_map<const Value*, int>& conflictCounts(
00091         const Variable& variable) const;
00092 
00101     bool contains(const Variable& variable) const
00102     {
00103         return m_conflictCounts.find(&variable) != m_conflictCounts.end();
00104     }
00105 
00107     void clear() { m_conflictCounts.clear(); }
00108 
00110     bool empty() { return m_conflictCounts.empty(); }
00111 
00112   private:
00114     ConflictCounts(const ConflictCounts&);
00115 
00117     ConflictCounts& operator=(const ConflictCounts&);
00118 
00126     void compute2(const Constraint& constraint);
00127 
00137     void compute(
00138         const Constraint& constraint,
00139         const Variable& variable,
00140         Domain& domain);
00141 
00143     typedef hash_map<const Variable*, hash_map<const Value*, int> > cc_type;
00144 
00146     const Decomposition& m_decomposition;
00147 
00149     cc_type m_conflictCounts;
00150 
00152     const Variable* m_variable;
00153 };
00154 
00155 
00156 CSP_NAMESPACE_END(caches);
00157 CSP_NAMESPACE_END(csp);
00158 
00159 
00160 #endif // _CSP_KERNEL_ConflictCounts_H
00161 
00162 // Local Variables:
00163 // mode: C++
00164 // End:

Generated on Wed May 25 12:21:13 2005 for csp.kdevelop by  doxygen 1.3.9.1