aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::SetTerminalNodePolicy< GUM_SCALAR > Class Template Reference

Implementation of a Terminal Node Policy that maps nodeid to a set of value. More...

#include <agrum/base/multidim/FunctionGraphUtilities/terminalNodePolicies/SetTerminalNodePolicy.h>

Collaboration diagram for gum::SetTerminalNodePolicy< GUM_SCALAR >:

Public Member Functions

 ~SetTerminalNodePolicy ()
Terminal Node Creation and Destruction
void addTerminalNode (const NodeId &n, const GUM_SCALAR &v)
 Insert a new terminal node with given value.
void eraseTerminalNode (const NodeId &n)
 Remove node matching given id.
void clearAllTerminalNodes ()
 Erase all terminal nodes.
Terminal Nodes Existence
bool existsTerminalNodeWithId (const NodeId &n) const
 Returns true if a terminal node matching this id exists.
bool existsTerminalNodeWithValue (const GUM_SCALAR &v) const
 Returns true if a terminal node matching this value exists.
Terminal Nodes value and id access
const GUM_SCALAR & terminalNodeValue (const NodeId &n) const
 Returns the value of the terminal node that has the given id.
const NodeIdterminalNodeId (const GUM_SCALAR &v) const
 Returns the id of the terminal node that has the given value.

Iterator on Terminal Nodes

HashTable< NodeId, GUM_SCALAR * > _map_
 The mapping between NodeIds and Value Sets.
HashTableConstIteratorSafe< NodeId, GUM_SCALAR * > _mappy_
 The mapping between NodeIds and Value Sets.
const NodeId jocker = 0
 The mapping between NodeIds and Value Sets.
void beginValues () const
 Initializes the constant safe iterator on terminal nodes.
bool hasValue () const
 Indicates if constant safe iterator has reach end of terminal nodes list.
void nextValue () const
 Increments the constant safe iterator.
const GUM_SCALAR & value () const
 Returns the value of the current terminal nodes pointed by the constant safe iterator.
const NodeIdid () const
 Returns the id of the current terminal nodes pointed by the constant safe iterator.

Detailed Description

template<typename GUM_SCALAR>
class gum::SetTerminalNodePolicy< GUM_SCALAR >

Implementation of a Terminal Node Policy that maps nodeid to a set of value.

Definition at line 69 of file SetTerminalNodePolicy.h.

Constructor & Destructor Documentation

◆ ~SetTerminalNodePolicy()

template<typename GUM_SCALAR>
gum::SetTerminalNodePolicy< GUM_SCALAR >::~SetTerminalNodePolicy ( )
inline

Definition at line 71 of file SetTerminalNodePolicy.h.

void clearAllTerminalNodes()
Erase all terminal nodes.

References clearAllTerminalNodes().

Here is the call graph for this function:

Member Function Documentation

◆ addTerminalNode()

template<typename GUM_SCALAR>
void gum::SetTerminalNodePolicy< GUM_SCALAR >::addTerminalNode ( const NodeId & n,
const GUM_SCALAR & v )
inline

Insert a new terminal node with given value.

Definition at line 79 of file SetTerminalNodePolicy.h.

79 {
80 if (_map_.exists(n)) *(_map_[n]) += v;
81 _map_.insert(n, new GUM_SCALAR(v));
82 }
Implementation of a Terminal Node Policy that maps nodeid to a set of value.
HashTable< NodeId, GUM_SCALAR * > _map_
The mapping between NodeIds and Value Sets.

References _map_.

◆ beginValues()

template<typename GUM_SCALAR>
void gum::SetTerminalNodePolicy< GUM_SCALAR >::beginValues ( ) const
inline

Initializes the constant safe iterator on terminal nodes.

Definition at line 131 of file SetTerminalNodePolicy.h.

131{ _mappy_ = _map_.cbeginSafe(); }
HashTableConstIteratorSafe< NodeId, GUM_SCALAR * > _mappy_
The mapping between NodeIds and Value Sets.

References _map_, and _mappy_.

◆ clearAllTerminalNodes()

template<typename GUM_SCALAR>
void gum::SetTerminalNodePolicy< GUM_SCALAR >::clearAllTerminalNodes ( )
inline

Erase all terminal nodes.

Definition at line 90 of file SetTerminalNodePolicy.h.

90 {
91 for (auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
92 delete nodeIter.val();
93 _map_.clear();
94 }

References _map_.

Referenced by ~SetTerminalNodePolicy().

Here is the caller graph for this function:

◆ eraseTerminalNode()

template<typename GUM_SCALAR>
void gum::SetTerminalNodePolicy< GUM_SCALAR >::eraseTerminalNode ( const NodeId & n)
inline

Remove node matching given id.

Definition at line 85 of file SetTerminalNodePolicy.h.

85 {
86 if (_map_.exists(n)) _map_.erase(n);
87 }

References _map_.

◆ existsTerminalNodeWithId()

template<typename GUM_SCALAR>
bool gum::SetTerminalNodePolicy< GUM_SCALAR >::existsTerminalNodeWithId ( const NodeId & n) const
inline

Returns true if a terminal node matching this id exists.

Definition at line 103 of file SetTerminalNodePolicy.h.

103{ return _map_.exists(n); }

References _map_.

◆ existsTerminalNodeWithValue()

template<typename GUM_SCALAR>
bool gum::SetTerminalNodePolicy< GUM_SCALAR >::existsTerminalNodeWithValue ( const GUM_SCALAR & v) const
inline

Returns true if a terminal node matching this value exists.

Definition at line 106 of file SetTerminalNodePolicy.h.

106{ return terminalNodeId(v) != 0; }
const NodeId & terminalNodeId(const GUM_SCALAR &v) const
Returns the id of the terminal node that has the given value.

References terminalNodeId().

Here is the call graph for this function:

◆ hasValue()

template<typename GUM_SCALAR>
bool gum::SetTerminalNodePolicy< GUM_SCALAR >::hasValue ( ) const
inline

Indicates if constant safe iterator has reach end of terminal nodes list.

Definition at line 134 of file SetTerminalNodePolicy.h.

134{ return _mappy_ != _map_.cendSafe(); }

References _map_, and _mappy_.

◆ id()

template<typename GUM_SCALAR>
const NodeId & gum::SetTerminalNodePolicy< GUM_SCALAR >::id ( ) const
inline

Returns the id of the current terminal nodes pointed by the constant safe iterator.

Definition at line 145 of file SetTerminalNodePolicy.h.

145{ return _mappy_.key(); }

References _mappy_.

◆ nextValue()

template<typename GUM_SCALAR>
void gum::SetTerminalNodePolicy< GUM_SCALAR >::nextValue ( ) const
inline

Increments the constant safe iterator.

Definition at line 137 of file SetTerminalNodePolicy.h.

137{ ++_mappy_; }

References _mappy_.

◆ terminalNodeId()

template<typename GUM_SCALAR>
const NodeId & gum::SetTerminalNodePolicy< GUM_SCALAR >::terminalNodeId ( const GUM_SCALAR & v) const
inline

Returns the id of the terminal node that has the given value.

Definition at line 118 of file SetTerminalNodePolicy.h.

118 {
119 for (auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
120 if (*(nodeIter.val()) == v) return nodeIter.key();
121 return jocker;
122 }
const NodeId jocker
The mapping between NodeIds and Value Sets.

References _map_, and jocker.

Referenced by existsTerminalNodeWithValue().

Here is the caller graph for this function:

◆ terminalNodeValue()

template<typename GUM_SCALAR>
const GUM_SCALAR & gum::SetTerminalNodePolicy< GUM_SCALAR >::terminalNodeValue ( const NodeId & n) const
inline

Returns the value of the terminal node that has the given id.

Definition at line 115 of file SetTerminalNodePolicy.h.

115{ return *(_map_[n]); }

References _map_.

◆ value()

template<typename GUM_SCALAR>
const GUM_SCALAR & gum::SetTerminalNodePolicy< GUM_SCALAR >::value ( ) const
inline

Returns the value of the current terminal nodes pointed by the constant safe iterator.

Definition at line 141 of file SetTerminalNodePolicy.h.

141{ return *(_mappy_.val()); }

References _mappy_.

Member Data Documentation

◆ _map_

template<typename GUM_SCALAR>
HashTable< NodeId, GUM_SCALAR* > gum::SetTerminalNodePolicy< GUM_SCALAR >::_map_
private

◆ _mappy_

template<typename GUM_SCALAR>
HashTableConstIteratorSafe< NodeId, GUM_SCALAR* > gum::SetTerminalNodePolicy< GUM_SCALAR >::_mappy_
mutableprivate

The mapping between NodeIds and Value Sets.

Definition at line 150 of file SetTerminalNodePolicy.h.

Referenced by beginValues(), hasValue(), id(), nextValue(), and value().

◆ jocker

template<typename GUM_SCALAR>
const NodeId gum::SetTerminalNodePolicy< GUM_SCALAR >::jocker = 0
private

The mapping between NodeIds and Value Sets.

Definition at line 152 of file SetTerminalNodePolicy.h.

Referenced by terminalNodeId().


The documentation for this class was generated from the following file: