30 #ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_SET_TERMINAL_NODE_POLICY_H 31 #define GUM_MULTI_DIM_FUNCTION_GRAPH_SET_TERMINAL_NODE_POLICY_H 33 #include <agrum/tools/graphs/parts/nodeGraphPart.h> 47 template <
typename GUM_SCALAR >
59 if (_map_.exists(n)) *(_map_[n]) += v;
60 _map_.insert(n,
new GUM_SCALAR(v));
65 if (_map_.exists(n)) _map_.erase(n);
70 for (
auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
71 delete nodeIter.val();
98 for (
auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
99 if (*(nodeIter.val()) == v)
return nodeIter.key();
113 bool hasValue()
const {
return _mappy_ != _map_.cendSafe(); }
120 const GUM_SCALAR&
value()
const {
return *(_mappy_.val()); }
const GUM_SCALAR & value() const
Returns the value of the current terminal nodes pointed by the constant safe iterator.
INLINE void emplace(Args &&... args)
const GUM_SCALAR & terminalNodeValue(const NodeId &n) const
Returns the value of the terminal node that has the given id.
HashTable< NodeId, GUM_SCALAR *> _map_
The mapping between NodeIds and Value Sets.
const NodeId & id() const
Returns the id of the current terminal nodes pointed by the constant safe iterator.
void eraseTerminalNode(const NodeId &n)
Remove node matching given id.
const NodeId jocker
The mapping between NodeIds and Value Sets.
const NodeId & terminalNodeId(const GUM_SCALAR &v) const
Returns the id of the terminal node that has the given value.
Implementation of a Terminal Node Policy that maps nodeid to a set of value.
bool hasValue() const
Indicates if constant safe iterator has reach end of terminal nodes list.
void beginValues() const
Initializes the constant safe iterator on terminal nodes.
bool existsTerminalNodeWithId(const NodeId &n) const
Returns true if a terminal node matching this id exists.
void nextValue() const
Increments the constant safe iterator.
void addTerminalNode(const NodeId &n, const GUM_SCALAR &v)
Insert a new terminal node with given value.
bool existsTerminalNodeWithValue(const GUM_SCALAR &v) const
Returns true if a terminal node matching this value exists.
HashTableConstIteratorSafe< NodeId, GUM_SCALAR *> _mappy_
The mapping between NodeIds and Value Sets.
void clearAllTerminalNodes()
Erase all terminal nodes.