29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 41 template <
typename GUM_SCALAR >
43 static Idx __abstract_id = 0;
44 return ++__abstract_id;
48 template <
typename GUM_SCALAR >
49 HashTable< Idx, const MultiDimImplementation< GUM_SCALAR >* >&
51 static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR >* >
53 # ifdef GUM_DEBUG_MODE 57 static bool first_time =
true;
61 __debug__::__inc_deletion(
62 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__multidims);
70 template <
typename GUM_SCALAR >
71 HashTable< const MultiDimImplementation< GUM_SCALAR >*,
Idx >&
73 static HashTable< const MultiDimImplementation< GUM_SCALAR >*,
Idx >
75 # ifdef GUM_DEBUG_MODE 79 static bool first_time =
true;
83 __debug__::__inc_deletion(
84 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__multidim_ids);
88 return __multidim_ids;
92 template <
typename GUM_SCALAR >
95 # ifdef GUM_DEBUG_MODE 99 static bool first_time =
true;
103 __debug__::__inc_deletion(
104 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__ids);
112 template <
typename GUM_SCALAR >
113 HashTable< Idx, const Sequence< const DiscreteVariable* >* >&
115 static HashTable< Idx, const Sequence< const DiscreteVariable* >* > __vars;
116 # ifdef GUM_DEBUG_MODE 120 static bool first_time =
true;
124 __debug__::__inc_deletion(
125 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__vars);
133 template <
typename GUM_SCALAR >
135 static HashTable< Idx, Size > __size;
136 # ifdef GUM_DEBUG_MODE 140 static bool first_time =
true;
144 __debug__::__inc_deletion(
145 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)&__size);
153 template <
typename GUM_SCALAR >
155 const MultiDimImplementation< GUM_SCALAR >& multidim) {
157 GUM_CONSTRUCTOR(ScheduleMultiDim);
161 if (__multidim2id().exists(&multidim)) {
163 __id = __multidim2id().operator[](&multidim);
173 __id2multidim().insert(__id, &multidim);
174 __multidim2id().insert(&multidim, __id);
177 __id2refs().insert(__id, 1);
180 const Sequence< const DiscreteVariable* >* vars =
181 new Sequence< const DiscreteVariable* >(multidim.variablesSequence());
182 __id2vars().insert(__id, vars);
185 __id2size().insert(__id, multidim.domainSize());
190 template <
typename GUM_SCALAR >
192 const MultiDimDecorator< GUM_SCALAR >& multidim) {
194 GUM_CONSTRUCTOR(ScheduleMultiDim);
196 const MultiDimImplementation< GUM_SCALAR >* impl = multidim.content();
200 if (__multidim2id().exists(impl)) {
202 __id = __multidim2id().operator[](impl);
212 __id2multidim().insert(__id, impl);
213 __multidim2id().insert(impl, __id);
216 __id2refs().insert(__id, 1);
219 const Sequence< const DiscreteVariable* >* vars =
220 new Sequence< const DiscreteVariable* >(multidim.variablesSequence());
221 __id2vars().insert(__id, vars);
224 __id2size().insert(__id, multidim.domainSize());
229 template <
typename GUM_SCALAR >
231 const Sequence< const DiscreteVariable* >& vars) :
240 const Sequence< const DiscreteVariable* >* new_vars =
241 new Sequence< const DiscreteVariable* >(vars);
247 for (
const auto var : *new_vars)
248 size *= var->domainSize();
254 template <
typename GUM_SCALAR >
256 const ScheduleMultiDim< GUM_SCALAR >& from) :
267 template <
typename GUM_SCALAR >
293 template <
typename GUM_SCALAR >
295 operator=(
const ScheduleMultiDim< GUM_SCALAR >& from) {
297 if (
__id != from.__id) {
326 template <
typename GUM_SCALAR >
328 operator==(
const ScheduleMultiDim< GUM_SCALAR >& m)
const {
329 return (
__id == m.__id);
333 template <
typename GUM_SCALAR >
335 operator!=(
const ScheduleMultiDim< GUM_SCALAR >& m)
const {
336 return (
__id != m.__id);
341 template <
typename GUM_SCALAR >
342 INLINE
const MultiDimImplementation< GUM_SCALAR >&
349 template <
typename GUM_SCALAR >
355 template <
typename GUM_SCALAR >
361 template <
typename GUM_SCALAR >
362 INLINE
const Sequence< const DiscreteVariable* >&
368 template <
typename GUM_SCALAR >
374 template <
typename GUM_SCALAR >
376 const MultiDimImplementation< GUM_SCALAR >& m) {
383 "the multidim table has already been " 384 "wrapped into a ScheduleMultidim with another id");
393 const MultiDimImplementation< GUM_SCALAR >* impl =
396 if (impl == &m)
return;
409 const Sequence< const DiscreteVariable* >& m_vars = m.variablesSequence();
410 Sequence< const DiscreteVariable* >* vars =
411 const_cast< Sequence< const DiscreteVariable* >*
>(
421 template <
typename GUM_SCALAR >
423 const MultiDimDecorator< GUM_SCALAR >& m) {
428 template <
typename GUM_SCALAR >
430 std::stringstream str;
437 }
catch (NotFound&) { str <<
__id; }
const Sequence< const DiscreteVariable *> & variablesSequence() const
returns the set of variables involved in the multidim
static HashTable< const MultiDimImplementation< GUM_SCALAR > *, Idx > & __multidim2id()
returns the id corresponding to a given multidim
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
ScheduleMultiDim(const MultiDimImplementation< GUM_SCALAR > &)
constructs a ScheduleMultiDim containing an already built implementation
std::string toString() const
displays the content of the multidim
bool isAbstract() const
returns whether the ScheduleMultiDim contains a real multiDimImplementation
Idx id() const
returns the id of the ScheduleMultiDim
void erase(const Key &key)
Removes a given element from the hash table.
Size domainSize() const
returns the domain size of the multidim
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool operator!=(const ScheduleMultiDim< GUM_SCALAR > &) const
checks whether two ScheduleMultiDim are related to different tables
ScheduleMultiDim< GUM_SCALAR > & operator=(const ScheduleMultiDim< GUM_SCALAR > &)
copy operator
~ScheduleMultiDim()
destructor
const MultiDimImplementation< GUM_SCALAR > & multiDim() const
returns the multiDimImplementation actually contained in the ScheduleMultiDim
static HashTable< Idx, const Sequence< const DiscreteVariable *> *> & __id2vars()
returns a table with the variables of the table corresponding to id
static HashTable< Idx, Idx > & __id2refs()
returns a table indicating how many ScheduleMultiDim have the same id
static Idx __newId()
returns a new distinct ID for each abtract scheduleMultiDim
static HashTable< Idx, Size > & __id2size()
returns a table with the domain size of the table corresponding to id
Idx __id
the unique Id of the ScheduleMultiDim
static HashTable< Idx, const MultiDimImplementation< GUM_SCALAR > *> & __id2multidim()
returns a mapping from id to multidimImplementations
std::size_t Size
In aGrUM, hashed values are unsigned long int.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
void setMultiDim(const MultiDimImplementation< GUM_SCALAR > &)
sets a new multiDimImplementation inside the wrapper
bool operator==(const ScheduleMultiDim< GUM_SCALAR > &) const
checks whether two ScheduleMultiDim are related to the same table
#define GUM_ERROR(type, msg)