aGrUM  0.16.0
multiDimInterface_inl.h
Go to the documentation of this file.
1 
30 // to ease IDE parser
32 
33 namespace gum {
34  // Swap two variables in this multidim.
35  INLINE
37  const DiscreteVariable& y) {
38  if (!contains(x)) { GUM_ERROR(NotFound, "could not find the variable"); }
39 
40  if (contains(y)) {
41  GUM_ERROR(DuplicateElement, "variable " << y << " already in MultiDim");
42  }
43 
44  if (x.domainSize() != y.domainSize()) {
45  GUM_ERROR(OperationNotAllowed, "incompatible variables");
46  }
47 
48  _replace(&x, &y);
49  }
50 
51 } /* namespace gum */
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual Size domainSize() const =0
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)=0
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void replace(const DiscreteVariable &x, const DiscreteVariable &y)
Replace variables in this multidim.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55