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

RandomIndexes.h

00001 // RandomIndexes.h -- The interface to a cache of random indexes.
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: RandomIndexes_8h-source.html,v 1.1 2005/05/25 12:37:18 tudor Exp $
00028 
00029 #ifndef _CSP_CACHES_RandomIndexes_H
00030 #define _CSP_CACHES_RandomIndexes_H
00031 
00032 
00033 CSP_NAMESPACE_BEGIN(csp);
00034 CSP_NAMESPACE_BEGIN(caches);
00035 
00036 
00040 class CSP_API RandomIndexes
00041 {
00042   public:
00044     RandomIndexes(const Decomposition& decomposition, Randomizer& randomizer) :
00045         m_decomposition(decomposition),
00046         m_variable(0),
00047         m_randomizer(randomizer) {}
00048 
00050     void init(const vlist_type& uninstantiatedVariables);
00051 
00060     void init(const Variable& variable, Domain& domain);
00061 
00063     void done();
00064 
00070     void setVariable(const Variable& variable)
00071     {
00072         m_variable = &variable;
00073     }
00074 
00081     size_t randomIndex(const Value& value) const;
00082 
00090     const hash_map<const Value*, int>& randomIndexes(
00091         const Variable& variable) const;
00092 
00101     bool contains(const Variable& variable) const
00102     {
00103         return m_randomIndexes.find(&variable) != m_randomIndexes.end();
00104     }
00105 
00107     void clear() { m_randomIndexes.clear(); }
00108 
00110     bool empty() { return m_randomIndexes.empty(); }
00111 
00112   private:
00114     RandomIndexes(const RandomIndexes&);
00115 
00117     RandomIndexes& operator=(const RandomIndexes&);
00118 
00120     typedef hash_map<const Variable*, hash_map<const Value*, int> > ri_type;
00121 
00123     const Decomposition& m_decomposition;
00124 
00126     ri_type m_randomIndexes;
00127 
00129     const Variable* m_variable;
00130 
00132     Randomizer& m_randomizer;
00133 };
00134 
00135 
00136 CSP_NAMESPACE_END(caches);
00137 CSP_NAMESPACE_END(csp);
00138 
00139 
00140 #endif // _CSP_KERNEL_RandomIndexes_H
00141 
00142 // Local Variables:
00143 // mode: C++
00144 // End:

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