aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::ExactTerminalNodePolicy< GUM_ELEMENT > Class Template Reference

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

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

Inheritance diagram for gum::ExactTerminalNodePolicy< GUM_ELEMENT >:
Collaboration diagram for gum::ExactTerminalNodePolicy< GUM_ELEMENT >:

Public Member Functions

Terminal Node Creation and Destruction
void addTerminalNode (const NodeId &n, const GUM_ELEMENT &v) override
 Insert a new terminal node with given value.
void eraseTerminalNode (const NodeId &n) override
 Remove node matching given id.
void clearAllTerminalNodes () override
 Erase all terminal nodes.
Terminal Nodes Existence
bool existsTerminalNodeWithId (const NodeId &n) const override
 Returns true if a terminal node matching this id exists.
bool existsTerminalNodeWithValue (const GUM_ELEMENT &v) const override
 Returns true if a terminal node matching this value exists.
Terminal Nodes value and id access
const GUM_ELEMENT & terminalNodeValue (const NodeId &n) const override
 Returns the value of the terminal node that has the given id.
const NodeIdterminalNodeId (const GUM_ELEMENT &v) const override
 Returns the id of the terminal node that has the given value.
Iterator on Terminal Nodes
void beginValues () const override
 Initializes the constant safe iterator on terminal nodes.
bool hasValue () const override
 Indicates if constant safe iterator has reach end of terminal nodes list.
void nextValue () const override
 Increments the constant safe iterator.
const GUM_ELEMENT & value () const override
 Returns the value of the current terminal nodes pointed by the constant safe iterator.
const NodeIdid () const override
 Returns the id of the current terminal nodes pointed by the constant safe iterator.

Private Attributes

Bijection< NodeId, GUM_ELEMENT > _map_
BijectionIteratorSafe< NodeId, GUM_ELEMENT > _mappy_

Detailed Description

template<typename GUM_ELEMENT>
class gum::ExactTerminalNodePolicy< GUM_ELEMENT >

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

Definition at line 69 of file ExactTerminalNodePolicy.h.

Member Function Documentation

◆ addTerminalNode()

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

Insert a new terminal node with given value.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 49 of file ExactTerminalNodePolicy_tpl.h.

50 {
51 _map_.insert(n, v);
52 }
Implementation of a Terminal Node Policy that maps nodeid directly to value.
Bijection< NodeId, GUM_ELEMENT > _map_

References _map_.

◆ beginValues()

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

Initializes the constant safe iterator on terminal nodes.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 87 of file ExactTerminalNodePolicy_tpl.h.

87 {
88 _mappy_ = _map_.beginSafe();
89 }
BijectionIteratorSafe< NodeId, GUM_ELEMENT > _mappy_

References _map_, and _mappy_.

◆ clearAllTerminalNodes()

template<typename GUM_ELEMENT>
void gum::ExactTerminalNodePolicy< GUM_ELEMENT >::clearAllTerminalNodes ( )
overridevirtual

Erase all terminal nodes.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 60 of file ExactTerminalNodePolicy_tpl.h.

60 {
61 _map_.clear();
62 }

References _map_.

Referenced by gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::clear().

Here is the caller graph for this function:

◆ eraseTerminalNode()

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

Remove node matching given id.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 55 of file ExactTerminalNodePolicy_tpl.h.

55 {
56 _map_.eraseFirst(n);
57 }

References _map_.

◆ existsTerminalNodeWithId()

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

Returns true if a terminal node matching this id exists.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 65 of file ExactTerminalNodePolicy_tpl.h.

65 {
66 return _map_.existsFirst(n);
67 }

References _map_.

Referenced by gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::isTerminalNode().

Here is the caller graph for this function:

◆ existsTerminalNodeWithValue()

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

Returns true if a terminal node matching this value exists.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 70 of file ExactTerminalNodePolicy_tpl.h.

71 {
72 return _map_.existsSecond(v);
73 }

References _map_.

◆ hasValue()

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

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

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 92 of file ExactTerminalNodePolicy_tpl.h.

92 {
93 return _mappy_ != _map_.endSafe();
94 }

◆ id()

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

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

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 107 of file ExactTerminalNodePolicy_tpl.h.

107 {
108 return _mappy_.first();
109 }

References _mappy_.

◆ nextValue()

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

Increments the constant safe iterator.

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 97 of file ExactTerminalNodePolicy_tpl.h.

97 {
98 ++_mappy_;
99 }

References _mappy_.

◆ terminalNodeId()

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

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

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 82 of file ExactTerminalNodePolicy_tpl.h.

82 {
83 return _map_.first(v);
84 }

◆ terminalNodeValue()

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

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

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 77 of file ExactTerminalNodePolicy_tpl.h.

77 {
78 return _map_.second(n);
79 }

Referenced by gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::get(), gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::nodeValue(), and gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::toDot().

Here is the caller graph for this function:

◆ value()

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

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

Implements gum::ITerminalNodePolicy< GUM_ELEMENT >.

Definition at line 102 of file ExactTerminalNodePolicy_tpl.h.

102 {
103 return _mappy_.second();
104 }

References _mappy_.

Referenced by gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::set().

Here is the caller graph for this function:

Member Data Documentation

◆ _map_

template<typename GUM_ELEMENT>
Bijection< NodeId, GUM_ELEMENT > gum::ExactTerminalNodePolicy< GUM_ELEMENT >::_map_
private

◆ _mappy_

template<typename GUM_ELEMENT>
BijectionIteratorSafe< NodeId, GUM_ELEMENT > gum::ExactTerminalNodePolicy< GUM_ELEMENT >::_mappy_
mutableprivate

Definition at line 136 of file ExactTerminalNodePolicy.h.

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


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