aGrUM  0.16.0
gum::InternalNode Class Reference

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

#include <agrum/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 __nodeVar.

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.

◆ 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 __setNodeVar().

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 __nodeSons, and __nodeVar.

51  {
52  GUM_CONSTRUCTOR(InternalNode);
53  __nodeVar = v;
54  __nodeSons = sons;
55  }
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122
const DiscreteVariable * __nodeVar
Variable associated to such node.
Definition: internalNode.h:105
InternalNode()
Default Constructor Creates an empty node with no variable attached.

◆ ~InternalNode()

gum::InternalNode::~InternalNode ( )

Class destructors.

Definition at line 60 of file internalNode.cpp.

References __nodeSons, __nodeVar, and deallocateNodeSons().

60  {
61  GUM_DESTRUCTOR(InternalNode);
63  }
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122
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:

Member Function Documentation

◆ __setNodeVar()

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

Set the node variable.

Definition at line 100 of file internalNode.cpp.

References __nodeSons, __nodeVar, and allocateNodeSons().

Referenced by InternalNode(), and setNodeVar().

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

◆ addParent()

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

Adds a parent.

Definition at line 108 of file internalNode.cpp.

References __nodeParents.

108  {
109  __nodeParents.addLink(Parent(parent, modality));
110  }
LinkedList< Parent > __nodeParents
The list of the node&#39;s parent.
Definition: internalNode.h:125

◆ 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 ALLOCATE, and gum::DiscreteVariable::domainSize().

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__adjacentSwap(), and __setNodeVar().

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

◆ deallocateNodeSons()

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

Deallocates a NodeSons table.

Definition at line 79 of file internalNode.cpp.

References DEALLOCATE, and gum::DiscreteVariable::domainSize().

Referenced by setNode(), setNodeVar(), and ~InternalNode().

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

◆ nbSons()

◆ nodeVar()

◆ operator delete()

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

Delete operator.

Definition at line 76 of file internalNode_inl.h.

References gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

76  {
78  }
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 71 of file internalNode_inl.h.

References gum::SmallObjectAllocator::allocate(), and gum::SmallObjectAllocator::instance().

71  {
73  }
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 95 of file internalNode_inl.h.

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::_migrateNode(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::eraseNode(), and gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::toDot().

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

◆ parents() [2/2]

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

Returns the list of parents.

Definition at line 98 of file internalNode_inl.h.

98  {
99  return __nodeParents.list();
100  }
LinkedList< Parent > __nodeParents
The list of the node&#39;s parent.
Definition: internalNode.h:125

◆ removeParent()

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

Removes a parent.

Definition at line 112 of file internalNode.cpp.

References __nodeParents.

112  {
113  __nodeParents.searchAndRemoveLink(Parent(parent, modality));
114  }
LinkedList< Parent > __nodeParents
The list of the node&#39;s parent.
Definition: internalNode.h:125

◆ 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 86 of file internalNode.cpp.

References __nodeSons, __nodeVar, and deallocateNodeSons().

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

◆ setNodeVar()

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

Set the node variable.

Definition at line 95 of file internalNode.cpp.

References __nodeSons, __nodeVar, __setNodeVar(), and deallocateNodeSons().

95  {
97  __setNodeVar(v);
98  }
void __setNodeVar(const DiscreteVariable *v)
Set the node variable.
static void deallocateNodeSons(const DiscreteVariable *v, NodeId *s)
Deallocates a NodeSons table.
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122
const DiscreteVariable * __nodeVar
Variable associated to such node.
Definition: internalNode.h:105
+ 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 84 of file internalNode_inl.h.

References gum::Parent::modality.

84  {
85  __nodeSons[modality] = son;
86  }
NodeId son(Idx modality) const
Returns the son at a given index.
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122

◆ son()

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

Returns the son at a given index.

Definition at line 89 of file internalNode_inl.h.

References gum::Parent::modality.

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__checkIsomorphism(), gum::Regress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::__compute(), gum::MultiDimFunctionGraphOperator< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::__compute(), gum::StructuredPlaner< double >::__recurArgMaxCopy(), gum::StructuredPlaner< double >::__recurExtractOptPol(), gum::TreeOperator< GUM_SCALAR, COMBINEOPERATOR, TerminalNodePolicy >::__xPloreDT2(), gum::TreeRegress< GUM_SCALAR, COMBINEOPERATOR, PROJECTOPERATOR, TerminalNodePolicy >::__xPloreVFunc(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::_migrateNode(), gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::_reduce(), gum::StatesChecker::addState(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::copy(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::copyAndMultiplyByScalar(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::copyAndReassign(), gum::MultiDimFunctionGraphGenerator::generate(), gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::get(), gum::StatesCounter::incState(), gum::StatesCounter::nodeSon(), gum::StructuredPlaner< double >::optimalPolicy2String(), gum::MultiDimFunctionGraphProjector< GUM_SCALAR, FUNCTOR, TerminalNodePolicy >::project(), and gum::MultiDimFunctionGraph< bool, ExactTerminalNodePolicy >::toDot().

89 { return __nodeSons[modality]; }
NodeId * __nodeSons
Table of sons of the node.
Definition: internalNode.h:122
+ Here is the caller 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.

Referenced by addParent(), and removeParent().

◆ __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.

Referenced by __setNodeVar(), InternalNode(), setNode(), setNodeVar(), and ~InternalNode().

◆ __nodeVar

const DiscreteVariable* gum::InternalNode::__nodeVar
private

Variable associated to such node.

Definition at line 105 of file internalNode.h.

Referenced by __setNodeVar(), InternalNode(), setNode(), setNodeVar(), and ~InternalNode().


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