aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
internalNode_inl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by 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
) :
parentId
(
src
.
parentId
),
modality
(
src
.
modality
) {}
41
42
INLINE
43
void
*
Parent
::
operator
new
(
size_t
s
) {
return
SmallObjectAllocator
::
instance
().
allocate
(
s
); }
44
45
INLINE
46
void
Parent
::
operator
delete
(
void
*
p
) {
47
SmallObjectAllocator
::
instance
().
deallocate
(
p
,
sizeof
(
Parent
));
48
}
49
50
INLINE
51
bool
Parent
::
operator
==(
const
Parent
&
comp
)
const
{
52
if
((
comp
.
parentId
==
this
->
parentId
) && (
comp
.
modality
==
this
->
modality
))
return
true
;
53
return
false
;
54
}
55
56
INLINE
57
bool
Parent
::
operator
!=(
const
Parent
&
comp
)
const
{
return
!(
comp
== *
this
); }
58
59
INLINE
60
Parent&
Parent
::
operator
=(
const
Parent
&
src
) {
61
this
->
parentId
=
src
.
parentId
;
62
this
->
modality
=
src
.
modality
;
63
return
*
this
;
64
}
65
66
INLINE
67
void
*
InternalNode
::
operator
new
(
size_t
s
) {
68
return
SmallObjectAllocator
::
instance
().
allocate
(
s
);
69
}
70
71
INLINE
72
void
InternalNode
::
operator
delete
(
void
*
p
) {
73
SmallObjectAllocator
::
instance
().
deallocate
(
p
,
sizeof
(
InternalNode
));
74
}
75
76
INLINE
77
const
DiscreteVariable
*
InternalNode
::
nodeVar
()
const
{
return
_nodeVar_
; }
78
79
INLINE
80
void
InternalNode
::
setSon
(
Idx
modality
,
NodeId
son
) {
_nodeSons_
[
modality
] =
son
; }
81
82
INLINE
83
NodeId
InternalNode
::
son
(
Idx
modality
)
const
{
return
_nodeSons_
[
modality
]; }
84
85
INLINE
86
Idx
InternalNode
::
nbSons
()
const
{
return
_nodeVar_
->
domainSize
(); }
87
88
INLINE
89
Link
<
Parent
>*
InternalNode
::
parents
() {
return
_nodeParents_
.
list
(); }
90
91
INLINE
92
const
Link
<
Parent
>*
InternalNode
::
parents
()
const
{
return
_nodeParents_
.
list
(); }
93
}
// namespace gum
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643