aGrUM
0.20.2
a C++ library for (probabilistic) graphical models
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
v
w
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
v
Variables
Typedefs
Enumerations
+
Enumerator
a
c
e
f
g
h
i
l
p
s
t
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
v
+
Enumerations
a
b
c
e
f
i
k
l
n
p
r
s
t
+
Enumerator
a
b
c
d
e
f
i
l
m
n
o
p
r
s
t
u
v
+
Related Functions
b
c
d
f
g
h
l
m
n
o
p
r
s
t
+
Files
File List
+
File Members
+
All
a
b
d
e
f
g
i
l
m
n
o
r
s
t
u
v
w
Functions
Variables
Enumerations
Enumerator
+
Macros
a
b
d
e
f
g
i
l
m
r
s
t
u
v
argMaxSet_tpl.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
/** @file
23
* @brief Outlined implementation of ArgMaxSet
24
*
25
* @author Jean-Christophe MAGNAN
26
*/
27
28
#
include
<
agrum
/
tools
/
core
/
argMaxSet
.
h
>
29
30
31
namespace
gum
{
32
33
// ###########################################################################
34
// CNL
35
// ###########################################################################
36
37
// ============================================================================
38
// Constructor
39
// ============================================================================
40
template
<
typename
GUM_SCALAR_VAL,
typename
GUM_SCALAR_SEQ >
41
ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::ArgMaxSet() {
42
GUM_CONSTRUCTOR(ArgMaxSet);
43
argMaxSeq__ =
new
Sequence< GUM_SCALAR_SEQ >();
44
}
45
46
// ============================================================================
47
// Constructor
48
// ============================================================================
49
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
50
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
ArgMaxSet
(
51
const
GUM_SCALAR_VAL
&
val
,
52
const
GUM_SCALAR_SEQ
&
elem
) {
53
GUM_CONSTRUCTOR
(
ArgMaxSet
);
54
argMaxSeq__
=
new
Sequence
<
GUM_SCALAR_SEQ
>();
55
argMaxSeq__
->
insert
(
elem
);
56
val__
=
val
;
57
}
58
59
// ============================================================================
60
// Copy Constructor
61
// ============================================================================
62
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
63
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
ArgMaxSet
(
64
const
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
src
) {
65
GUM_CONS_CPY
(
ArgMaxSet
);
66
argMaxSeq__
=
new
Sequence
<
GUM_SCALAR_SEQ
>();
67
this
->
operator
+=(
src
);
68
val__
=
src
.
value
();
69
}
70
71
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
72
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
73
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
operator
=(
74
const
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
src
) {
75
this
->
argMaxSeq__
->
clear
();
76
this
->
operator
+=(
src
);
77
val__
=
src
.
value
();
78
return
*
this
;
79
}
80
81
// ============================================================================
82
// Destructor
83
// ============================================================================
84
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
85
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::~
ArgMaxSet
() {
86
GUM_DESTRUCTOR
(
ArgMaxSet
);
87
delete
argMaxSeq__
;
88
}
89
90
// ###########################################################################
91
// Operators
92
// ###########################################################################
93
94
// ============================================================================
95
// Ajout d'un élément
96
// ============================================================================
97
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
98
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
99
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
operator
+=(
100
const
GUM_SCALAR_SEQ
&
elem
) {
101
argMaxSeq__
->
insert
(
elem
);
102
return
*
this
;
103
}
104
105
// ============================================================================
106
// Use to insert the content of another set inside this one
107
// ============================================================================
108
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
109
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
110
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
operator
+=(
111
const
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
src
) {
112
for
(
auto
iter
=
src
.
beginSafe
();
iter
!=
src
.
endSafe
(); ++
iter
)
113
if
(!
argMaxSeq__
->
exists
(*
iter
))
argMaxSeq__
->
insert
(*
iter
);
114
return
*
this
;
115
}
116
117
// ============================================================================
118
// Compares two ArgMaxSet to check if they are equals
119
// ============================================================================
120
template
<
typename
GUM_SCALAR_VAL
,
typename
GUM_SCALAR_SEQ
>
121
bool
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>::
operator
==(
122
const
ArgMaxSet
<
GUM_SCALAR_VAL
,
GUM_SCALAR_SEQ
>&
compared
)
const
{
123
if
(
val__
!=
compared
.
value
())
return
false
;
124
for
(
auto
iter
=
compared
.
beginSafe
();
iter
!=
compared
.
endSafe
(); ++
iter
)
125
if
(!
argMaxSeq__
->
exists
(*
iter
))
return
false
;
126
for
(
auto
iter
=
this
->
beginSafe
();
iter
!=
this
->
endSafe
(); ++
iter
)
127
if
(!
compared
.
exists
(*
iter
))
return
false
;
128
return
true
;
129
}
130
131
}
// End of namespace gum
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:669