48#ifndef GUM_MULTI_DIM_DECORATOR_H
49#define GUM_MULTI_DIM_DECORATOR_H
80 template <
typename GUM_ELEMENT >
93 GUM_ELEMENT empty_value = (GUM_ELEMENT)0);
133 virtual void erase(std::string_view name)
final;
143 bool empty()
const final;
192 void fill(
const GUM_ELEMENT& d)
const final;
212 void populate(
const std::vector< GUM_ELEMENT >& v)
const final;
218 void apply(std::function< GUM_ELEMENT(GUM_ELEMENT) > f)
const final;
225 GUM_ELEMENT
reduce(std::function< GUM_ELEMENT(GUM_ELEMENT, GUM_ELEMENT) > f,
226 GUM_ELEMENT base)
const final;
290#include <agrum/base/multidim/implementations/multiDimDecorator_tpl.h>
Base class for discrete random variable.
Class for assigning/browsing values to tuples of discrete variables.
MultiDimContainer()
Default constructor.
void erase(const DiscreteVariable &var) final
Removes a var from the variables of the multidimensional matrix.
void populate(const std::vector< GUM_ELEMENT > &v) const final
Automatically fills this MultiDimContainer with the values in v.
MultiDimDecorator< GUM_ELEMENT > * newFactory() const override=0
Default implementation of MultiDimContainer::set().
Idx pos(const DiscreteVariable &var) const final
Returns the index of a variable.
const MultiDimImplementation< GUM_ELEMENT > * content() const final
Returns the implementation for this object (may be *this).
void fill(const GUM_ELEMENT &d) const final
Default implementation of MultiDimContainer::set().
bool empty() const final
Returns true if no var is in *this.
void setLastNotification(const Instantiation &i) final
Listen to setLast in a given Instantiation.
const Sequence< const DiscreteVariable * > & variablesSequence() const final
Returns a const ref to the sequence of DiscreteVariable*.
MultiDimDecorator(MultiDimImplementation< GUM_ELEMENT > *aContent=nullptr, GUM_ELEMENT empty_value=(GUM_ELEMENT) 0)
Class constructor.
std::string toString(const Instantiation *i) const override
Default implementation of MultiDimContainer::set().
const DiscreteVariable & variable(Idx) const final
Returns a const ref to the ith var.
void swapContent_(MultiDimImplementation< GUM_ELEMENT > *aContent) const
protected method to swap the implementation behind the Tensor
void setDecNotification(const Instantiation &i) final
Listen to increment in each recorded Instantiation.
MultiDimDecorator< GUM_ELEMENT > & operator=(const MultiDimDecorator &from) noexcept
copy operator
void beginMultipleChanges() final
Default implementation of MultiDimContainer::set().
void setIncNotification(const Instantiation &i) final
Listen to increment in a given Instantiation.
GUM_ELEMENT & get_(const Instantiation &i) const final
Return a data, given a Instantiation - final method.
virtual void notifyChange() const final
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
GUM_ELEMENT empty_value_
value of the MultiDimDecorator if no dimension.
bool contains(const DiscreteVariable &var) const final
Returns true if var is in *this.
Idx nbrDim() const final
Returns the number of vars in the multidimensional container.
GUM_ELEMENT reduce(std::function< GUM_ELEMENT(GUM_ELEMENT, GUM_ELEMENT) > f, GUM_ELEMENT base) const final
compute lfold for this container
~MultiDimDecorator() override
Class destructor.
void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) final
Listen to changes in a given Instantiation.
void set(const Instantiation &i, const GUM_ELEMENT &value) const final
Default implementation of MultiDimContainer::set().
void setChangeNotification(const Instantiation &i) final
Listen to an assignment of a value in a Instantiation.
void setFirstNotification(const Instantiation &i) final
Listen to setFirst in a given Instantiation.
MultiDimImplementation< GUM_ELEMENT > * content_
The true container.
void add(const DiscreteVariable &v) final
Adds a new var to the variables of the multidimensional matrix.
Size domainSize() const final
Returns the product of the variables domain size.
bool unregisterSlave(Instantiation &i) final
Unregister i as a slave of this MultiDimAdressable.
void apply(std::function< GUM_ELEMENT(GUM_ELEMENT) > f) const final
Apply a function on every element of the container.
GUM_ELEMENT get(const Instantiation &i) const final
Default implementation of MultiDimContainer::get().
void endMultipleChanges() final
Default implementation of MultiDimContainer::set().
bool registerSlave(Instantiation &i) final
Register i as a slave of this MultiDimAdressable.
<agrum/base/multidim/multiDimImplementation.h>
The generic class for storing (ordered) sequences of objects.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Header of the MultiDimArray class.
gum is the global namespace for all aGrUM entities