aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::InternalNode Class Reference

Structure used to represent a node internal structure. More...

#include <agrum/tools/multidim/FunctionGraphUtilities/internalNode.h>

+ Collaboration diagram for gum::InternalNode:

Public Member Functions

Constructors and Destructors
 InternalNode ()
 Default Constructor Creates an empty node with no variable attached. More...
 
 InternalNode (const DiscreteVariable *v)
 Class constructor. More...
 
 InternalNode (const DiscreteVariable *v, NodeId *sons)
 Constructor. More...
 
 ~InternalNode ()
 Class destructors. More...
 
Allocators and Deallocators redefinition
void * operator new (size_t s)
 New operator. More...
 
void operator delete (void *p)
 Delete operator. More...
 
Node handlers
void setNode (const DiscreteVariable *v, NodeId *sons)
 Allows you to respecify the node, changing its attached variable as well as its son map. More...
 
Var handlers
void setNodeVar (const DiscreteVariable *v)
 Set the node variable. More...
 
const DiscreteVariablenodeVar () const
 Returns the node variable. More...
 
Sons handlers
void setSon (Idx modality, NodeId son)
 Sets the node's son. More...
 
NodeId son (Idx modality) const
 Returns the son at a given index. More...
 
Idx nbSons () const
 Returns the number of sons. More...
 
Parent handlers
void addParent (NodeId parent, Idx modality)
 Adds a parent. More...
 
void removeParent (NodeId parent, Idx modality)
 Removes a parent. More...
 
Link< Parent > * parents ()
 Returns the list of parents. More...
 
const Link< Parent > * parents () const
 Returns the list of parents. More...
 

Static Public Member Functions

Allocator/deallocator
static NodeIdallocateNodeSons (const DiscreteVariable *v)
 Allocates a table of nodeid of the size given in parameter. More...
 
static void deallocateNodeSons (const DiscreteVariable *v, NodeId *s)
 Deallocates a NodeSons table. More...
 

Detailed Description

Structure used to represent a node internal structure.

Definition at line 102 of file internalNode.h.

Constructor & Destructor Documentation

◆ InternalNode() [1/3]

gum::InternalNode::InternalNode ( )

Default Constructor Creates an empty node with no variable attached.

Definition at line 41 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

41  {
42  GUM_CONSTRUCTOR(InternalNode);
43  _nodeVar_ = nullptr;
44  }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ InternalNode() [2/3]

gum::InternalNode::InternalNode ( const DiscreteVariable v)
explicit

Class constructor.

Creates a node and attached the specified variable. Initializes the sons.

Definition at line 46 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

46  {
47  GUM_CONSTRUCTOR(InternalNode);
48  _setNodeVar_(v);
49  }
void _setNodeVar_(const DiscreteVariable *v)
Set the node variable.
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ InternalNode() [3/3]

gum::InternalNode::InternalNode ( const DiscreteVariable v,
NodeId sons 
)

Constructor.

Creates a node and attached the specified variable. Also attached the given on map (and will handle it by itself especially deallocate it)

Warning
You'd better known what you're doing if you're using this one. sons must have the size of domainSize of v or the program will fail!

Definition at line 51 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

51  {
52  GUM_CONSTRUCTOR(InternalNode);
53  _nodeVar_ = v;
54  _nodeSons_ = sons;
55  }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ ~InternalNode()

gum::InternalNode::~InternalNode ( )

Class destructors.

Definition at line 60 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

60  {
61  GUM_DESTRUCTOR(InternalNode);
63  }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

Member Function Documentation

◆ _setNodeVar_()

void gum::InternalNode::_setNodeVar_ ( const DiscreteVariable v)
private

Set the node variable.

Definition at line 99 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

99  {
100  _nodeVar_ = v;
102  }
static NodeId * allocateNodeSons(const DiscreteVariable *v)
Allocates a table of nodeid of the size given in parameter.
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

◆ addParent()

void gum::InternalNode::addParent ( NodeId  parent,
Idx  modality 
)

Adds a parent.

Definition at line 107 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

107  {
108  _nodeParents_.addLink(Parent(parent, modality));
109  }
LinkedList< Parent > _nodeParents_
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ allocateNodeSons()

NodeId * gum::InternalNode::allocateNodeSons ( const DiscreteVariable v)
static

Allocates a table of nodeid of the size given in parameter.

Definition at line 68 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

68  {
69  NodeId* sons = static_cast< NodeId* >(ALLOCATE(sizeof(NodeId) * v->domainSize()));
70  for (gum::Idx i = 0; i < v->domainSize(); ++i)
71  sons[i] = 0;
72  return sons;
73  }
#define ALLOCATE(x)
Size Idx
Type for indexes.
Definition: types.h:52
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ deallocateNodeSons()

void gum::InternalNode::deallocateNodeSons ( const DiscreteVariable v,
NodeId s 
)
static

Deallocates a NodeSons table.

Definition at line 78 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

78  {
79  DEALLOCATE(s, sizeof(NodeId) * v->domainSize());
80  }
#define DEALLOCATE(x, y)
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ nbSons()

INLINE Idx gum::InternalNode::nbSons ( ) const

Returns the number of sons.

Definition at line 86 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

86 { return _nodeVar_->domainSize(); }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
virtual Size domainSize() const =0
+ Here is the call graph for this function:

◆ nodeVar()

INLINE const DiscreteVariable * gum::InternalNode::nodeVar ( ) const

Returns the node variable.

Definition at line 77 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

77 { return _nodeVar_; }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
+ Here is the call graph for this function:

◆ operator delete()

INLINE void gum::InternalNode::operator delete ( void *  p)

Delete operator.

Definition at line 72 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

72  {
74  }
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()
InternalNode()
Default Constructor Creates an empty node with no variable attached.
+ Here is the call graph for this function:

◆ operator new()

INLINE void * gum::InternalNode::operator new ( size_t  s)

New operator.

Definition at line 67 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

67  {
69  }
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
+ Here is the call graph for this function:

◆ parents() [1/2]

INLINE Link< Parent > * gum::InternalNode::parents ( )

Returns the list of parents.

Definition at line 89 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

89 { return _nodeParents_.list(); }
LinkedList< Parent > _nodeParents_
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ parents() [2/2]

INLINE const Link< Parent > * gum::InternalNode::parents ( ) const

Returns the list of parents.

Definition at line 92 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

92 { return _nodeParents_.list(); }
LinkedList< Parent > _nodeParents_
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ removeParent()

void gum::InternalNode::removeParent ( NodeId  parent,
Idx  modality 
)

Removes a parent.

Definition at line 111 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

111  {
112  _nodeParents_.searchAndRemoveLink(Parent(parent, modality));
113  }
LinkedList< Parent > _nodeParents_
The list of the node&#39;s parent.
Definition: internalNode.h:125
+ Here is the call graph for this function:

◆ setNode()

void gum::InternalNode::setNode ( const DiscreteVariable v,
NodeId sons 
)

Allows you to respecify the node, changing its attached variable as well as its son map.

Warning
You'd better known what you're doing if you're using this one. sons must have the size of domainSize of v or the program will fail!

Definition at line 85 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

85  {
87  _nodeVar_ = v;
88  _nodeSons_ = sons;
89  }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

◆ setNodeVar()

void gum::InternalNode::setNodeVar ( const DiscreteVariable v)

Set the node variable.

Definition at line 94 of file internalNode.cpp.

References gum::Set< Key, Alloc >::emplace().

94  {
96  _setNodeVar_(v);
97  }
const DiscreteVariable * _nodeVar_
Variable associated to such node.
Definition: internalNode.h:105
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
void _setNodeVar_(const DiscreteVariable *v)
Set the node variable.
+ Here is the call graph for this function:

◆ setSon()

INLINE void gum::InternalNode::setSon ( Idx  modality,
NodeId  son 
)

Sets the node's son.

Definition at line 80 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

80 { _nodeSons_[modality] = son; }
NodeId son(Idx modality) const
Returns the son at a given index.
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

◆ son()

INLINE NodeId gum::InternalNode::son ( Idx  modality) const

Returns the son at a given index.

Definition at line 83 of file internalNode_inl.h.

References gum::Set< Key, Alloc >::emplace().

83 { return _nodeSons_[modality]; }
NodeId * _nodeSons_
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the call graph for this function:

Member Data Documentation

◆ _nodeParents_

LinkedList< Parent > gum::InternalNode::_nodeParents_
private

The list of the node's parent.

Definition at line 125 of file internalNode.h.

◆ _nodeSons_

NodeId* gum::InternalNode::_nodeSons_
private

Table of sons of the node.

Each son is bound to a modality of the variable. So those modalities are used has indexes for that table.

_____________________________
| | | | |
| son1 | son2 | son3 | son4 |
| ______| ______| ______| ______|
x1 x2 x3 x4

Definition at line 122 of file internalNode.h.

◆ _nodeVar_

const DiscreteVariable* gum::InternalNode::_nodeVar_
private

Variable associated to such node.

Definition at line 105 of file internalNode.h.


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