20 #ifndef DOXYGEN_SHOULD_SKIP_THIS 60 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
69 std::string name =
"SetInst does not contain this DiscreteVariable: ";
80 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
89 std::string name =
"SetInst does not contain this DiscreteVariable: ";
131 if (newVals >= (
Size)1 << v.domainSize())
GUM_ERROR(OutOfBounds,
"");
139 }
catch (NotFound&) {
140 std::string name =
"SetInst does not contain this DiscreteVariable: ";
151 if (newVals >= (
Size)1 << v->domainSize())
GUM_ERROR(OutOfBounds,
"");
159 }
catch (NotFound&) {
160 std::string name =
"SetInst does not contain this DiscreteVariable: ";
172 if (newVal >= (
Size)1 <<
__vars[varPos]->domainSize())
199 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
207 }
catch (NotFound&) {
208 std::string name =
"SetInst does not contain this DiscreteVariable: ";
219 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
227 }
catch (NotFound&) {
228 std::string name =
"SetInst does not contain this DiscreteVariable: ";
258 }
catch (NotFound&) {
259 std::string name =
"SetInst does not contain this DiscreteVariable: ";
280 }
catch (NotFound&) {
281 std::string name =
"SetInst does not contain this DiscreteVariable: ";
301 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
308 }
catch (NotFound&) {
309 std::string name =
"SetInst does not contain this DiscreteVariable: ";
320 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
328 }
catch (NotFound&) {
329 std::string name =
"SetInst does not contain this DiscreteVariable: ";
359 }
catch (NotFound&) {
360 std::string name =
"SetInst does not contain this DiscreteVariable: ";
381 }
catch (NotFound&) {
382 std::string name =
"SetInst does not contain this DiscreteVariable: ";
422 }
catch (NotFound&) {
423 std::string name =
"SetInst does not contain this DiscreteVariable: ";
445 }
catch (NotFound&) {
446 std::string name =
"SetInst does not contain this DiscreteVariable: ";
466 if (newVal >= v->domainSize())
GUM_ERROR(OutOfBounds,
"");
473 }
catch (NotFound&) {
474 std::string name =
"SetInst does not contain this DiscreteVariable: ";
485 if (newVal >= v.domainSize())
GUM_ERROR(OutOfBounds,
"");
493 }
catch (NotFound&) {
494 std::string name =
"SetInst does not contain this DiscreteVariable: ";
509 "Variable '" << v.name() <<
"' already exists in this SetInst");
523 GUM_ERROR(NotFound,
"Var does not exist in this SetInst");
544 for (
const auto var :
__vars)
545 s *= var->domainSize();
553 return __vars.pos(&k);
587 return __vals[__vars.pos(&var)];
593 return __vals[__vars.pos(var)];
600 if (
__vals[__vars.pos(var)] % 2 == 0) {
608 GUM_ERROR(NotFound,
"There is more than one value ");
635 GUM_ERROR(NotFound,
"There is more than one value ");
641 return *(__vars.atPos(i));
667 reorder(i.variablesSequence());
676 for (
Size p = 0; p < s; ++p)
686 INLINE
const Sequence< const DiscreteVariable* >&
711 Idx max = original.size();
714 for (
Idx i = 0; i < max; ++i) {
715 const DiscreteVariable* pv = original.atPos(i);
718 GUM_ASSERT(
pos(*pv) >= position);
748 const DiscreteVariable* y) {
749 __vars.setAtPos(__vars.pos(x), y);
753 #endif // DOXYGEN_SHOULD_SKIP_THIS const DiscreteVariable & variable(Idx i) const
Returns the variable at position i in the tuple.
void __chgVal(Idx varPos, Idx newVal)
Change the value of a variable.
Idx nbrDim() const
Returns the number of variables in the SetInst.
void clear()
Erase all variables from an SetInst.
void __erase(const DiscreteVariable &v)
Removes a variable from the sequence of vars.
Size domainSize() const
Returns the product of the variable's domain size in the SetInst.
virtual bool empty() const
Returns true if the SetInst is empty.
SetInst & chgVal(const DiscreteVariable &v, Idx newVal)
Assign newVal to variable v in the SetInst.
void add(const DiscreteVariable &v)
Adds a new variable in the SetInst.
SetInst & remVal(const DiscreteVariable &v, Idx newVal)
Remove newVal from the variable v in the SetInst.
bool end() const
Returns true if the SetInst reached the end.
gum is the global namespace for all aGrUM entities
bool rend() const
Returns true if the SetInst reached the rend.
bool contains(const DiscreteVariable &v) const
Indicates whether a given variable belongs to the SetInst.
const Sequence< const DiscreteVariable *> & variablesSequence() const
Returns the sequence of DiscreteVariable of this SetInst.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
void __swap(Idx i, Idx j)
Swap 2 vars in the SetInst.
void __add(const DiscreteVariable &v)
Adds a new var to the sequence of vars.
SetInst & interVal(const DiscreteVariable &v, Idx newVal)
Does an intersection (binary and) between the old value and new value.
void unsetOverflow()
Removes the flag overflow.
std::vector< Size > __vals
The current SetInst: the value of the tuple.
bool __overflow
The overflow flag.
SetInst & remVals(const DiscreteVariable &v, const Size newVal)
Remove newVal from the variable v in the SetInst.
Sequence< const DiscreteVariable *> __vars
The tuple of variables to be instantiated.
void erase(const DiscreteVariable &v)
Removes a variable from the SetInst.
Idx pos(const DiscreteVariable &v) const
Returns the position of the variable v.
SetInst & chgVals(const DiscreteVariable &v, const Size newVal)
Assign newVal to variable v in the SetInst.
Idx nbrOccurences(const DiscreteVariable &var) const
Returns the current value of the variable at position i.
Size vals(Idx i) const
Returns the current value of the variable at position i.
SetInst & chgDifVal(Idx varPos, const Size newVal)
Does the difference (binary or) between the old value and new value.
void unsetEnd()
Alias for unsetOverflow().
SetInst & addVal(const DiscreteVariable &v, Idx newVal)
Add newVal to variable v in the SetInst.
SetInst()
Default constructor: creates an empty tuple.
Size Idx
Type for indexes.
bool inOverflow() const
Indicates whether the current value of the tuple is correct or not.
Idx val(Idx i) const
Returns the current value of a variable at a given position.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
SetInst & interVals(const DiscreteVariable &v, const Size newVal)
Does an intersection (binary and) between the old value and new value.
SetInst & chgValIn(const SetInst &i)
Change all the values to match does in i.
SetInst & addVals(const DiscreteVariable &v, const Size newVal)
Add newVal to variable v in the SetInst.
Headers for the abstract base class for all multi dimensionnal containers.
void __chgVals(Idx varPos, const Size newVal)
Change the value of a variable.
#define GUM_ERROR(type, msg)
~SetInst()
Class destructor.
void reorder(const Sequence< const DiscreteVariable * > &v)
Reorder the variables given v.