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

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

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

+ Inheritance diagram for gum::ExactTerminalNodePolicy< GUM_SCALAR >:
+ Collaboration diagram for gum::ExactTerminalNodePolicy< GUM_SCALAR >:

Public Member Functions

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

Detailed Description

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

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

Definition at line 50 of file ExactTerminalNodePolicy.h.

Member Function Documentation

◆ addTerminalNode()

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

Insert a new terminal node with given value.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 58 of file ExactTerminalNodePolicy.h.

58 { _map_.insert(n, v); }
void insert(const T1 &first, const T2 &second)
Inserts a new association in the gum::Bijection.
Bijection< NodeId, GUM_SCALAR > _map_

◆ beginValues()

template<typename GUM_SCALAR >
void gum::ExactTerminalNodePolicy< GUM_SCALAR >::beginValues ( ) const
inlinevirtual

Initializes the constant safe iterator on terminal nodes.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 97 of file ExactTerminalNodePolicy.h.

97 { _mappy_ = _map_.beginSafe(); }
Bijection< NodeId, GUM_SCALAR > _map_
iterator_safe beginSafe() const
Returns the safe iterator at the beginning of the gum::Bijection.
BijectionIteratorSafe< NodeId, GUM_SCALAR > _mappy_

◆ clearAllTerminalNodes()

template<typename GUM_SCALAR >
void gum::ExactTerminalNodePolicy< GUM_SCALAR >::clearAllTerminalNodes ( )
inlinevirtual

Erase all terminal nodes.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 64 of file ExactTerminalNodePolicy.h.

64 { _map_.clear(); }
Bijection< NodeId, GUM_SCALAR > _map_
void clear()
Removes all the associations from the gum::Bijection.

◆ eraseTerminalNode()

template<typename GUM_SCALAR >
void gum::ExactTerminalNodePolicy< GUM_SCALAR >::eraseTerminalNode ( const NodeId n)
inlinevirtual

Remove node matching given id.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 61 of file ExactTerminalNodePolicy.h.

61 { _map_.eraseFirst(n); }
Bijection< NodeId, GUM_SCALAR > _map_
void eraseFirst(const T1 &first)
Erases an association containing the given first element.

◆ existsTerminalNodeWithId()

template<typename GUM_SCALAR >
bool gum::ExactTerminalNodePolicy< GUM_SCALAR >::existsTerminalNodeWithId ( const NodeId n) const
inlinevirtual

Returns true if a terminal node matching this id exists.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 73 of file ExactTerminalNodePolicy.h.

73 { return _map_.existsFirst(n); }
Bijection< NodeId, GUM_SCALAR > _map_
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.

◆ existsTerminalNodeWithValue()

template<typename GUM_SCALAR >
bool gum::ExactTerminalNodePolicy< GUM_SCALAR >::existsTerminalNodeWithValue ( const GUM_SCALAR &  v) const
inlinevirtual

Returns true if a terminal node matching this value exists.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 76 of file ExactTerminalNodePolicy.h.

76 { return _map_.existsSecond(v); }
Bijection< NodeId, GUM_SCALAR > _map_
bool existsSecond(const T2 &second) const
Returns true if second is the second element in a pair in the gum::Bijection.

◆ hasValue()

template<typename GUM_SCALAR >
bool gum::ExactTerminalNodePolicy< GUM_SCALAR >::hasValue ( ) const
inlinevirtual

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

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 100 of file ExactTerminalNodePolicy.h.

100 { return _mappy_ != _map_.endSafe(); }
Bijection< NodeId, GUM_SCALAR > _map_
BijectionIteratorSafe< NodeId, GUM_SCALAR > _mappy_
const iterator_safe & endSafe() const noexcept
Returns the safe iterator at the end of the gum::Bijection.

◆ id()

template<typename GUM_SCALAR >
const NodeId& gum::ExactTerminalNodePolicy< GUM_SCALAR >::id ( ) const
inlinevirtual

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

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 111 of file ExactTerminalNodePolicy.h.

111 { return _mappy_.first(); }
BijectionIteratorSafe< NodeId, GUM_SCALAR > _mappy_
const T1 & first() const
Returns the first element of the current association.

◆ nextValue()

template<typename GUM_SCALAR >
void gum::ExactTerminalNodePolicy< GUM_SCALAR >::nextValue ( ) const
inlinevirtual

Increments the constant safe iterator.

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 103 of file ExactTerminalNodePolicy.h.

103 { ++_mappy_; }
BijectionIteratorSafe< NodeId, GUM_SCALAR > _mappy_

◆ terminalNodeId()

template<typename GUM_SCALAR >
const NodeId& gum::ExactTerminalNodePolicy< GUM_SCALAR >::terminalNodeId ( const GUM_SCALAR &  v) const
inlinevirtual

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

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 88 of file ExactTerminalNodePolicy.h.

88 { return _map_.first(v); }
Bijection< NodeId, GUM_SCALAR > _map_
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.

◆ terminalNodeValue()

template<typename GUM_SCALAR >
const GUM_SCALAR& gum::ExactTerminalNodePolicy< GUM_SCALAR >::terminalNodeValue ( const NodeId n) const
inlinevirtual

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

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 85 of file ExactTerminalNodePolicy.h.

85 { return _map_.second(n); }
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Bijection< NodeId, GUM_SCALAR > _map_

◆ value()

template<typename GUM_SCALAR >
const GUM_SCALAR& gum::ExactTerminalNodePolicy< GUM_SCALAR >::value ( ) const
inlinevirtual

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

Implements gum::ITerminalNodePolicy< GUM_SCALAR >.

Definition at line 107 of file ExactTerminalNodePolicy.h.

107 { return _mappy_.second(); }
const T2 & second() const
Returns the second element of the current association.
BijectionIteratorSafe< NodeId, GUM_SCALAR > _mappy_

Member Data Documentation

◆ _map_

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

Definition at line 116 of file ExactTerminalNodePolicy.h.

◆ _mappy_

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

Definition at line 117 of file ExactTerminalNodePolicy.h.


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