25 #ifndef GUM_LEARNING_DB_ROW_H 26 #define GUM_LEARNING_DB_ROW_H 30 #include <initializer_list> 51 template <
typename T_DATA,
52 template <
typename >
class ALLOC = std::allocator >
67 DBRow(
const ALLOC< T_DATA >& alloc);
72 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
75 DBRow(
const std::size_t size,
76 const T_DATA default_value,
78 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
81 DBRow(std::initializer_list< T_DATA > list,
82 const double weight = 1.0,
83 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
86 template <
template <
typename >
class OTHER_ALLOC >
87 DBRow(
const std::vector< T_DATA, OTHER_ALLOC< T_DATA > >& cells,
88 const double weight = 1.0,
89 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
92 DBRow(std::vector< T_DATA, ALLOC< T_DATA > >&& cells,
93 const double weight = 1.0,
94 const ALLOC< T_DATA >& alloc = ALLOC< T_DATA >());
142 const T_DATA&
operator[](
const std::size_t i)
const;
154 const std::vector< T_DATA, ALLOC< T_DATA > >&
row() const noexcept;
157 std::vector< T_DATA, ALLOC< T_DATA > >&
row() noexcept;
160 const
double& weight() const noexcept;
163 double& weight() noexcept;
166 template < template < typename > class OTHER_ALLOC >
167 void setRow(const
std::vector< T_DATA, OTHER_ALLOC< T_DATA > >& new_row);
170 void setRow(
std::vector< T_DATA, ALLOC< T_DATA > >&& new_row);
176 std::
size_t size() const noexcept;
204 template <
typename TX_DATA,
template <
typename >
class OTHER_ALLOC >
DBRow< T_DATA, ALLOC > * clone() const
virtual copy constructor
double _weight
the weight of the row
DBRow()
default constructor
DBRow< T_DATA, ALLOC > & operator=(const DBRow< T_DATA, ALLOC > &from)
copy operator
gum is the global namespace for all aGrUM entities
ALLOC< T_DATA > allocator_type
std::vector< T_DATA, ALLOC< T_DATA > > _row
the row itself
void setRow(const std::vector< T_DATA, OTHER_ALLOC< T_DATA > > &new_row)
sets a new row (without changing the weight)
void setWeight(const double new_weight)
sets a new weight
The class for storing a record in a database.
const std::vector< T_DATA, ALLOC< T_DATA > > & row() const noexcept
returns the current row (without the weight)
const double & weight() const noexcept
returns the weight assigned to the DBRow
void resize(const std::size_t new_size)
resize a given row, i.e., its number of elements
std::size_t size() const noexcept
returns the number of elements in the row
T_DATA & operator[](const std::size_t i)
returns the ith content of the row
void reserve(const std::size_t new_size)
reserve a size for the elements of a given row
ALLOC< T_DATA > getAllocator() const
returns the allocator used by the DBRow
void pushBack(const T_DATA &elt)
adds a new element at the end of the row
The class representing a record stored in a tabular database.