00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
00143
00144