aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::SetTerminalNodePolicy< GUM_ELEMENT > 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_ELEMENT >:

Public Member Functions

 ~SetTerminalNodePolicy ()
Terminal Node Creation and Destruction
void addTerminalNode (const NodeId &n, const GUM_ELEMENT &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_ELEMENT &v) const
 Returns true if a terminal node matching this value exists.
Terminal Nodes value and id access
const GUM_ELEMENT & terminalNodeValue (const NodeId &n) const
 Returns the value of the terminal node that has the given id.
const NodeIdterminalNodeId (const GUM_ELEMENT &v) const
 Returns the id of the terminal node that has the given value.

Iterator on Terminal Nodes

HashTable< NodeId, GUM_ELEMENT * > _map_
 The mapping between NodeIds and Value Sets.
HashTableConstIteratorSafe< NodeId, GUM_ELEMENT * > _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_ELEMENT & 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_ELEMENT>
class gum::SetTerminalNodePolicy< GUM_ELEMENT >

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_ELEMENT>
gum::SetTerminalNodePolicy< GUM_ELEMENT >::~SetTerminalNodePolicy ( )

Definition at line 49 of file SetTerminalNodePolicy_tpl.h.

49 {
51 }
void clearAllTerminalNodes()
Erase all terminal nodes.

References clearAllTerminalNodes().

Here is the call graph for this function:

Member Function Documentation

◆ addTerminalNode()

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

Insert a new terminal node with given value.

Definition at line 54 of file SetTerminalNodePolicy_tpl.h.

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

References _map_.

◆ beginValues()

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

Initializes the constant safe iterator on terminal nodes.

Definition at line 97 of file SetTerminalNodePolicy_tpl.h.

97 {
98 _mappy_ = _map_.cbeginSafe();
99 }
HashTableConstIteratorSafe< NodeId, GUM_ELEMENT * > _mappy_
The mapping between NodeIds and Value Sets.

References _map_, and _mappy_.

◆ clearAllTerminalNodes()

template<typename GUM_ELEMENT>
void gum::SetTerminalNodePolicy< GUM_ELEMENT >::clearAllTerminalNodes ( )

Erase all terminal nodes.

Definition at line 66 of file SetTerminalNodePolicy_tpl.h.

66 {
67 for (auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
68 delete nodeIter.val();
69 _map_.clear();
70 }

References _map_.

Referenced by ~SetTerminalNodePolicy().

Here is the caller graph for this function:

◆ eraseTerminalNode()

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

Remove node matching given id.

Definition at line 61 of file SetTerminalNodePolicy_tpl.h.

61 {
62 if (_map_.exists(n)) _map_.erase(n);
63 }

References _map_.

◆ existsTerminalNodeWithId()

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

Returns true if a terminal node matching this id exists.

Definition at line 73 of file SetTerminalNodePolicy_tpl.h.

73 {
74 return _map_.exists(n);
75 }

References _map_.

◆ existsTerminalNodeWithValue()

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

Returns true if a terminal node matching this value exists.

Definition at line 78 of file SetTerminalNodePolicy_tpl.h.

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

◆ hasValue()

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

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

Definition at line 102 of file SetTerminalNodePolicy_tpl.h.

102 {
103 return _mappy_ != _map_.cendSafe();
104 }

References _map_, and _mappy_.

◆ id()

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

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

Definition at line 117 of file SetTerminalNodePolicy_tpl.h.

117 {
118 return _mappy_.key();
119 }

◆ nextValue()

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

Increments the constant safe iterator.

Definition at line 107 of file SetTerminalNodePolicy_tpl.h.

107 {
108 ++_mappy_;
109 }

References _mappy_.

◆ terminalNodeId()

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

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

Definition at line 90 of file SetTerminalNodePolicy_tpl.h.

90 {
91 for (auto nodeIter = _map_.beginSafe(); nodeIter != _map_.endSafe(); ++nodeIter)
92 if (*(nodeIter.val()) == v) return nodeIter.key();
93 return jocker;
94 }
const NodeId jocker
The mapping between NodeIds and Value Sets.

References _map_, and jocker.

◆ terminalNodeValue()

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

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

Definition at line 85 of file SetTerminalNodePolicy_tpl.h.

85 {
86 return *(_map_[n]);
87 }

◆ value()

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

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

Definition at line 112 of file SetTerminalNodePolicy_tpl.h.

112 {
113 return *(_mappy_.val());
114 }

References _mappy_.

Member Data Documentation

◆ _map_

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

The mapping between NodeIds and Value Sets.

Definition at line 136 of file SetTerminalNodePolicy.h.

Referenced by addTerminalNode(), beginValues(), clearAllTerminalNodes(), eraseTerminalNode(), existsTerminalNodeWithId(), hasValue(), and terminalNodeId().

◆ _mappy_

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

The mapping between NodeIds and Value Sets.

Definition at line 137 of file SetTerminalNodePolicy.h.

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

◆ jocker

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

The mapping between NodeIds and Value Sets.

Definition at line 139 of file SetTerminalNodePolicy.h.

Referenced by terminalNodeId().


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