50#ifndef GUM_MULTIDIM_BUCKET_H
51#define GUM_MULTIDIM_BUCKET_H
89 template <
typename GUM_ELEMENT >
228 void compute(
bool force =
false)
const;
238 const std::string&
name()
const override;
253 Idx newval)
override;
366#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Set of pairs of elements with fast search for both elements.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
The class for generic Hash Tables.
Class for assigning/browsing values to tuples of discrete variables.
Abstract base class for all multi dimensionnal addressable.
Multidimensional matrix stored as an array in memory.
A multidim implementation for buckets.
Bijection< Instantiation *, Instantiation * > _instantiations_
Bijection between instantiations registered on this and their equivalent on bucket.
GUM_ELEMENT get(const Instantiation &i) const override
Returns the value pointed by i.
bool isBucketEmpty() const
Returns true if this bucket is empty.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
void setFirstNotification(const Instantiation &i) override
Listen to setFirst in a given Instantiation.
void setLastNotification(const Instantiation &i) override
Listen to setLast in a given Instantiation.
const gum::VariableSet & allVariables() const
Returns the sequence of all the variables contained in the bucket.
void erase(const MultiDimContainer< GUM_ELEMENT > &impl)
Remove a MultiDimContainer from this bucket.
void commitMultipleChanges_() override
Synchronize content after MultipleChanges.
gum::VariableSet _allVariables_
The set of all variables of the multidims in this bucket.
void changeNotification(const Instantiation &i, const DiscreteVariable *const var, Idx oldval, Idx newval) override
Listen to changes in a given Instantiation.
Size bufferSize() const
Returns the amount of memory allowed for this bucket.
MultiDimBucket(const MultiDimBucket< GUM_ELEMENT > &source)
Copy constructor.
void _initializeBuffer_()
Initialize the internal buffer.
Instantiation _allVarsInst_
Instantiation over all variable in this.
void setChangeNotification(const Instantiation &i) override
Listen to an assignment of a value in a Instantiation.
void _eraseVariable_(const DiscreteVariable *var)
Erase a variable from allVariables if no other multidimensional table uses it in this bucket.
GUM_ELEMENT _computeValue_(const Instantiation &value) const
Compute the value of the final table of this bucket given i.
~MultiDimBucket() override
Destructor.
void setIncNotification(const Instantiation &i) override
Listen to increment in a given Instantiation.
const HashTable< const MultiDimContainer< GUM_ELEMENT > *, Instantiation * > & multidims() const
Returns the MultiDimContainer and their respective Instantiation.
void _eraseBuffer_()
Clean the buffer and switch it's instantiation to this bucket.
void setBufferSize(Size amount)
Changes the amount of memory allowed for this bucket.
MultiDimArray< GUM_ELEMENT > * _bucket_
The result table of this bucket.
const MultiDimArray< GUM_ELEMENT > & bucket() const
Returns the MultiDimArray used by this MultiDimBucket.
Size _bufferSize_
The number of element allowed in bucket.
void add(const MultiDimContainer< GUM_ELEMENT > *impl)
Add a MultiDimContainer in the bucket.
MultiDimContainer< GUM_ELEMENT > * newFactory() const override
Default constructor.
const std::string & name() const override
Returns the real name of the multiDim implementation.
bool bucketChanged() const
Returns true if the bucket need re-computation since the last computation.
HashTable< const MultiDimContainer< GUM_ELEMENT > *, Instantiation * > _multiDims_
The set of MultiDimContainer in this bucket.
void add(const MultiDimContainer< GUM_ELEMENT > &impl)
Add a MultiDimContainer in the bucket.
MultiDimAdressable & getMasterRef() override
In order to insure the dereference for decorators, we need to virtualize the access to master pointer...
bool _changed_
Flag used to know if changes has occurred in the bucket since last computation.
GUM_ELEMENT & get_(const Instantiation &i) const override
Size bucketSize() const
Returns the number of MultiDimContainer in this bucket.
void erase(const MultiDimContainer< GUM_ELEMENT > *impl)
Remove a MultiDimContainer from this bucket.
bool registerSlave(Instantiation &i) override
Register i as a slave of this MultiDimAdressable.
void _addVariable_(const DiscreteVariable *var)
Add a variable to allVariables, and do nothing if var is already in the set.
bool unregisterSlave(Instantiation &i) override
Unregister i as a slave of this MultiDimAdressable.
void setDecNotification(const Instantiation &i) override
Listen to increment in each recorded Instantiation.
void compute(bool force=false) const
This method computes the final table of this bucket.
Size realSize() const override
Returns the real number of parameters used for this table.
MultiDimBucket(Size bufferSize=INT_MAX)
Default constructor.
std::string _name_
The class name.
bool contains(const MultiDimContainer< GUM_ELEMENT > &impl) const
Returns true if the MultiDimContainer is in this bucket.
HashTable< const Instantiation *, GUM_ELEMENT > _slavesValue_
This table is used to keep the last value computed for an instantiation when the value are computed o...
Abstract base class for all multi dimensionnal containers.
virtual std::string toString() const
Returns a representation of this MultiDimContainer.
MultiDimReadOnly()
Default constructor.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Header of the MultiDimArray class.
Implementation of the MultiDimBucket class.
Header of the MultiDimReadOnly class.
gum is the global namespace for all aGrUM entities
Set< const DiscreteVariable * > VariableSet