aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
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 >
51  const GUM_SCALAR_VAL& val,
52  const GUM_SCALAR_SEQ& elem) {
56  val__ = val;
57  }
58 
59  // ============================================================================
60  // Copy Constructor
61  // ============================================================================
62  template < typename GUM_SCALAR_VAL, typename GUM_SCALAR_SEQ >
67  this->operator+=(src);
68  val__ = src.value();
69  }
70 
71  template < typename GUM_SCALAR_VAL, typename GUM_SCALAR_SEQ >
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 >
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 >
100  const GUM_SCALAR_SEQ& 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 >
112  for (auto iter = src.beginSafe(); iter != src.endSafe(); ++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 >
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
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669