aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
internalNode_inl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/**
23
* @file
24
* @brief Inline implementation of the InternalNode class.
25
*
26
* @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
27
* @author Pierre-Henri WUILLEMIN(@LIP6) and Jean-Christophe MAGNAN and Christophe
28
* GONZALES(@AMU)
29
*/
30
31
#
include
<
agrum
/
tools
/
multidim
/
utils
/
FunctionGraphUtilities
/
internalNode
.
h
>
32
33
namespace
gum
{
34
35
INLINE
36
Parent
::
Parent
(
NodeId
pi
,
Idx
m
) :
parentId
(
pi
),
modality
(
m
) {}
37
38
39
INLINE
40
Parent
::
Parent
(
const
Parent
&
src
) :
41
parentId
(
src
.
parentId
),
modality
(
src
.
modality
) {}
42
43
INLINE
44
void
*
Parent
::
operator
new
(
size_t
s
) {
45
return
SmallObjectAllocator
::
instance
().
allocate
(
s
);
46
}
47
48
INLINE
49
void
Parent
::
operator
delete
(
void
*
p
) {
50
SmallObjectAllocator
::
instance
().
deallocate
(
p
,
sizeof
(
Parent
));
51
}
52
53
INLINE
54
bool
Parent
::
operator
==(
const
Parent
&
comp
)
const
{
55
if
((
comp
.
parentId
==
this
->
parentId
) && (
comp
.
modality
==
this
->
modality
))
56
return
true
;
57
return
false
;
58
}
59
60
INLINE
61
bool
Parent
::
operator
!=(
const
Parent
&
comp
)
const
{
return
!(
comp
== *
this
); }
62
63
INLINE
64
Parent&
Parent
::
operator
=(
const
Parent
&
src
) {
65
this
->
parentId
=
src
.
parentId
;
66
this
->
modality
=
src
.
modality
;
67
return
*
this
;
68
}
69
70
INLINE
71
void
*
InternalNode
::
operator
new
(
size_t
s
) {
72
return
SmallObjectAllocator
::
instance
().
allocate
(
s
);
73
}
74
75
INLINE
76
void
InternalNode
::
operator
delete
(
void
*
p
) {
77
SmallObjectAllocator
::
instance
().
deallocate
(
p
,
sizeof
(
InternalNode
));
78
}
79
80
INLINE
81
const
DiscreteVariable
*
InternalNode
::
nodeVar
()
const
{
return
nodeVar__
; }
82
83
INLINE
84
void
InternalNode
::
setSon
(
Idx
modality
,
NodeId
son
) {
85
nodeSons__
[
modality
] =
son
;
86
}
87
88
INLINE
89
NodeId
InternalNode
::
son
(
Idx
modality
)
const
{
return
nodeSons__
[
modality
]; }
90
91
INLINE
92
Idx
InternalNode
::
nbSons
()
const
{
return
nodeVar__
->
domainSize
(); }
93
94
INLINE
95
Link
<
Parent
>*
InternalNode
::
parents
() {
return
nodeParents__
.
list
(); }
96
97
INLINE
98
const
Link
<
Parent
>*
InternalNode
::
parents
()
const
{
99
return
nodeParents__
.
list
();
100
}
101
}
// namespace gum
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669