58 template <
typename GUM_ELEMENT >
69 template <
typename GUM_ELEMENT >
81 template <
typename GUM_ELEMENT >
89 (*iter)->forgetMaster();
94 template <
typename GUM_ELEMENT >
101 for (
const auto& w:
_vars_) {
102 if (w->name() == v.
name())
104 "A var with name '" << v.
name() <<
"' already exists in this instantiation");
116 iter != _slaveInstantiations_.endSafe();
118 (*iter)->addWithMaster(
this, v);
121 if (isInMultipleChangeMethod_()) _setNotCommitedChange_();
126 template <
typename GUM_ELEMENT >
140 (*iter)->eraseWithMaster(
this, v);
143 if (isInMultipleChangeMethod_()) _setNotCommitedChange_();
147 template <
typename GUM_ELEMENT >
148 MultiDimImplementation< GUM_ELEMENT >&
operator<<(MultiDimImplementation< GUM_ELEMENT >& array,
149 const DiscreteVariable& v) {
156 template <
typename GUM_ELEMENT >
164 if (!slave.
contains(*iter))
return false;
175 template <
typename GUM_ELEMENT >
181 template <
typename GUM_ELEMENT >
186 template <
typename GUM_ELEMENT >
191 template <
typename GUM_ELEMENT >
196 template <
typename GUM_ELEMENT >
200 if (v->name() ==
name)
return *v;
206 template <
typename GUM_ELEMENT >
211 template <
typename GUM_ELEMENT >
218 template <
typename GUM_ELEMENT >
225 template <
typename GUM_ELEMENT >
231 template <
typename GUM_ELEMENT >
236 template <
typename GUM_ELEMENT >
246 template <
typename GUM_ELEMENT >
256 template <
typename GUM_ELEMENT >
261 template <
typename GUM_ELEMENT >
267 template <
typename GUM_ELEMENT >
273 template <
typename GUM_ELEMENT >
279 template <
typename GUM_ELEMENT >
285 template <
typename GUM_ELEMENT >
291 template <
typename GUM_ELEMENT >
297 template <
typename GUM_ELEMENT >
299 static const std::string str =
"MultiDimImplementation";
303 template <
typename GUM_ELEMENT >
311 (**iter).replace(*x, *y);
315 template <
typename GUM_ELEMENT >
321 template <
typename GUM_ELEMENT >
323 return out << static_cast< const MultiDimContainer< GUM_ELEMENT >& >(array);
327 template <
typename GUM_ELEMENT >
333 template <
typename GUM_ELEMENT >
339 template <
typename GUM_ELEMENT >
344 template <
typename GUM_ELEMENT >
Base class for discrete random variable.
virtual Size domainSize() const =0
Exception : a similar element already exists.
Class for assigning/browsing values to tuples of discrete variables.
void synchronizeWithMaster(const MultiDimAdressable *m)
Force the variables sequence to be the same as the master one.
bool contains(const DiscreteVariable &v) const final
Indicates whether a given variable belongs to the Instantiation.
Idx nbrDim() const final
Returns the number of variables in the Instantiation.
Generic doubly linked lists.
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
MultiDimContainer()
Default constructor.
<agrum/base/multidim/multiDimImplementation.h>
Idx pos(const DiscreteVariable &v) const override
Returns the index of a variable.
void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
void beginMultipleChanges() override
Call this method before doing important changes in this MultiDimContainer.
Size domainSize() const override
Returns the product of the variables domain size.
bool isInMultipleChangeMethod_() const
Get the actual change method of this MultiDimImplementation.
const Sequence< const DiscreteVariable * > & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
float compressionRate() const
The compression ratio of the table (depending on the type of implementation).
const DiscreteVariable & variable(Idx i) const override
Returns a const ref to the ith var.
_InternalChangeState_ _internalChangeState_
The current change state.
MultiDimImplementation()
Default constructor.
bool registerSlave(Instantiation &slave) override
Register i as a slave of this MultiDimAdressable.
bool unregisterSlave(Instantiation &slave) override
Unregister i as a slave of this MultiDimAdressable.
const List< Instantiation * > & slaves_() const
Returns a constant reference over the list of slaved instantiations.
bool empty() const override
Returns true if no var is in *this.
Sequence< const DiscreteVariable * > _vars_
List of discrete variables (dimensions).
const MultiDimImplementation< GUM_ELEMENT > * content() const final
Returns the implementation for this object (may be *this).
const std::string & basename() const
Returns the base class name of this MultiDimImplementation.
void endMultipleChanges() override
Call this method after doing important changes in this MultiDimContainer.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
void _setNotCommitedChange_()
Change the internalChangeState to NOT_COMMITTED_CHANGE.
bool isCommitNeeded_() const
Get the actual state of *this.
virtual void commitMultipleChanges_()
Synchronize content after MultipleChanges.
_InternalChangeMethod_ _internalChangeMethod_
The current change method.
List< Instantiation * > _slaveInstantiations_
List of instantiations of the tuples (sequences) of variables.
virtual void invert_(Idx p1, Idx p2)
Inverts variables at position p1 and p2.
Idx nbrDim() const override
Returns the number of vars in the multidimensional container.
virtual const GUM_ELEMENT * data() const noexcept
Returns a pointer to the contiguous data buffer, or nullptr if the implementation does not store data...
~MultiDimImplementation() override
Class destructor.
virtual Size realSize() const =0
Returns the real number of parameters used for this table.
bool contains(const DiscreteVariable &v) const override
Returns true if var is in *this.
virtual const std::string & name() const =0
Returns the real name of the multiDim implementation.
Size _domainSize_
This MultiDimImplementation domain size.
Exception : the element we looked for cannot be found.
Exception : out of bound.
The generic class for storing (ordered) sequences of objects.
SequenceIteratorSafe< Key > iterator_safe
Types for STL compliance.
const std::string & name() const
returns the name of the variable
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Headers of gum::MultiDimImplementation.
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree