aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBRow.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47#ifndef GUM_LEARNING_DB_ROW_H
48#define GUM_LEARNING_DB_ROW_H
49
50#include <cstddef>
51#include <cstring>
52#include <memory>
53#include <vector>
54
55#include <agrum/agrum.h>
56
57#include <initializer_list>
58
59namespace gum {
60
61 namespace learning {
62
74 template < typename T_DATA >
75 class DBRow {
76 public:
77 // ##########################################################################
79 // ##########################################################################
80
82
85
87 DBRow(const std::size_t size, const double weight = 1.0);
88
90 DBRow(const std::size_t size, const T_DATA default_value, const double weight);
91
93 DBRow(std::initializer_list< T_DATA > list, const double weight = 1.0);
94
96 DBRow(const std::vector< T_DATA >& cells, const double weight = 1.0);
97
99 DBRow(std::vector< T_DATA >&& cells, const double weight = 1.0);
100
102 DBRow(const DBRow< T_DATA >& from);
103
106
109
112
114
115
116 // ##########################################################################
118 // ##########################################################################
119
121
124
127
129
132 T_DATA& operator[](const std::size_t i);
133
135
138 const T_DATA& operator[](const std::size_t i) const;
139
141
142
143 // ##########################################################################
145 // ##########################################################################
146
148
150 const std::vector< T_DATA >& row() const noexcept;
151
153 std::vector< T_DATA >& row() noexcept;
154
156 const double& weight() const noexcept;
157
159 double& weight() noexcept;
160
162 void setRow(const std::vector< T_DATA >& new_row);
163
165 void setRow(std::vector< T_DATA >&& new_row);
166
168 void setWeight(const double new_weight);
169
171 std::size_t size() const noexcept;
172
174 void resize(const std::size_t new_size);
175
177 void reserve(const std::size_t new_size);
178
180 void pushBack(const T_DATA& elt);
181
183 void pushBack(T_DATA&& elt);
184
186
187
188 protected:
190 std::vector< T_DATA > row_;
191
193 double weight_{1.0f};
194 };
195
196 } /* namespace learning */
197
198} /* namespace gum */
199
202
203#endif /* GUM_LEARNING_DB_ROW_H */
The class representing a record stored in a tabular database.
DBRow(std::initializer_list< TX_DATA > list, const double weight=1.0)
DBRow(const DBRow< TX_DATA > &from)
void setRow(const std::vector< TX_DATA > &new_row)
DBRow(const std::size_t size, const TX_DATA default_value, const double weight)
DBRow< TX_DATA > * clone() const
const TX_DATA & operator[](const std::size_t i) const
DBRow(DBRow< TX_DATA > &&from)
TX_DATA & operator[](const std::size_t i)
DBRow()
default constructor
DBRow(const std::size_t size, const double weight=1.0)
DBRow(std::vector< TX_DATA > &&cells, const double weight=1.0)
DBRow(const std::vector< TX_DATA > &cells, const double weight=1.0)
const std::vector< TX_DATA > & row() const noexcept
DBRow< TX_DATA > & operator=(DBRow< TX_DATA > &&from)
DBRow< TX_DATA > & operator=(const DBRow< TX_DATA > &from)
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.