aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::learning::DBRow< T_DATA > Class Template Reference

The class for storing a record in a database. More...

#include <agrum/base/database/DBRow.h>

Collaboration diagram for gum::learning::DBRow< T_DATA >:
[legend]

Public Member Functions

Constructors / Destructors
 DBRow ()
 default constructor
 DBRow (const std::size_t size, const double weight=1.0)
 constructs a row of a given size with missing values
 DBRow (const std::size_t size, const T_DATA default_value, const double weight)
 constructor with a given size for the row
 DBRow (std::initializer_list< T_DATA > list, const double weight=1.0)
 initializer list constructor
 DBRow (const std::vector< T_DATA > &cells, const double weight=1.0)
 initializer from a vector of cells
 DBRow (std::vector< T_DATA > &&cells, const double weight=1.0)
 initializer with a move from a vector of cells
 DBRow (const DBRow< T_DATA > &from)
 copy constructor
 DBRow (DBRow< T_DATA > &&from)
 move constructor
DBRow< T_DATA > * clone () const
 virtual copy constructor
 ~DBRow ()
 destructor
Operators
DBRow< T_DATA > & operator= (const DBRow< T_DATA > &from)
 copy operator
DBRow< T_DATA > & operator= (DBRow< T_DATA > &&from)
 move operator
T_DATA & operator[] (const std::size_t i)
 returns the ith content of the row
const T_DATA & operator[] (const std::size_t i) const
 returns the ith content of the row
Accessors / Modifiers
const std::vector< T_DATA > & row () const noexcept
 returns the current row (without the weight)
std::vector< T_DATA > & row () noexcept
 returns the current row (without the weight)
const double & weight () const noexcept
 returns the weight assigned to the DBRow
double & weight () noexcept
 returns the weight assigned to the DBRow
void setRow (const std::vector< T_DATA > &new_row)
 sets a new row (without changing the weight)
void setRow (std::vector< T_DATA > &&new_row)
 sets a new row (without changing the weight)
void setWeight (const double new_weight)
 sets a new weight
std::size_t size () const noexcept
 returns the number of elements in the row
void resize (const std::size_t new_size)
 resize a given row, i.e., its number of elements
void reserve (const std::size_t new_size)
 reserve a size for the elements of a given row
void pushBack (const T_DATA &elt)
 adds a new element at the end of the row
void pushBack (T_DATA &&elt)
 adds a new element at the end of the row

Protected Attributes

std::vector< T_DATA > row_
 the row itself
double weight_ {1.0f}
 the weight of the row

Detailed Description

template<typename T_DATA>
class gum::learning::DBRow< T_DATA >

The class for storing a record in a database.

Learning algorithms use DatabaseTable instances as their input data. Those are represented essentially as vectors of DBRow instances. Each DBRow is encoded as a vector of elements plus a weight (which is a double). To be quite general, the types of the elements stored into the DBRow are specified as template parameters of the DBRow.

Definition at line 75 of file DBRow.h.

Constructor & Destructor Documentation

◆ DBRow() [1/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( )

default constructor

◆ DBRow() [2/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( const std::size_t size,
const double weight = 1.0 )

constructs a row of a given size with missing values

◆ DBRow() [3/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( const std::size_t size,
const T_DATA default_value,
const double weight )

constructor with a given size for the row

◆ DBRow() [4/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( std::initializer_list< T_DATA > list,
const double weight = 1.0 )

initializer list constructor

◆ DBRow() [5/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( const std::vector< T_DATA > & cells,
const double weight = 1.0 )

initializer from a vector of cells

◆ DBRow() [6/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( std::vector< T_DATA > && cells,
const double weight = 1.0 )

initializer with a move from a vector of cells

◆ DBRow() [7/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( const DBRow< T_DATA > & from)

copy constructor

◆ DBRow() [8/8]

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::DBRow ( DBRow< T_DATA > && from)

move constructor

◆ ~DBRow()

template<typename T_DATA>
gum::learning::DBRow< T_DATA >::~DBRow ( )

destructor

Member Function Documentation

◆ clone()

template<typename T_DATA>
DBRow< T_DATA > * gum::learning::DBRow< T_DATA >::clone ( ) const
nodiscard

virtual copy constructor

◆ operator=() [1/2]

template<typename T_DATA>
DBRow< T_DATA > & gum::learning::DBRow< T_DATA >::operator= ( const DBRow< T_DATA > & from)

copy operator

◆ operator=() [2/2]

template<typename T_DATA>
DBRow< T_DATA > & gum::learning::DBRow< T_DATA >::operator= ( DBRow< T_DATA > && from)

move operator

◆ operator[]() [1/2]

template<typename T_DATA>
T_DATA & gum::learning::DBRow< T_DATA >::operator[] ( const std::size_t i)

returns the ith content of the row

Warning
This method does not check that there are at least i+1 elements in the row. If this is not the case, you will probably get a segmentation fault.

◆ operator[]() [2/2]

template<typename T_DATA>
const T_DATA & gum::learning::DBRow< T_DATA >::operator[] ( const std::size_t i) const

returns the ith content of the row

Warning
This method does not check that there are at least i+1 elements in the row. If this is not the case, you will probably get a segmentation fault.

◆ pushBack() [1/2]

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::pushBack ( const T_DATA & elt)

adds a new element at the end of the row

◆ pushBack() [2/2]

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::pushBack ( T_DATA && elt)

adds a new element at the end of the row

◆ reserve()

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::reserve ( const std::size_t new_size)

reserve a size for the elements of a given row

◆ resize()

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::resize ( const std::size_t new_size)

resize a given row, i.e., its number of elements

◆ row() [1/2]

template<typename T_DATA>
const std::vector< T_DATA > & gum::learning::DBRow< T_DATA >::row ( ) const
noexcept

returns the current row (without the weight)

◆ row() [2/2]

template<typename T_DATA>
std::vector< T_DATA > & gum::learning::DBRow< T_DATA >::row ( )
noexcept

returns the current row (without the weight)

◆ setRow() [1/2]

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::setRow ( const std::vector< T_DATA > & new_row)

sets a new row (without changing the weight)

◆ setRow() [2/2]

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::setRow ( std::vector< T_DATA > && new_row)

sets a new row (without changing the weight)

◆ setWeight()

template<typename T_DATA>
void gum::learning::DBRow< T_DATA >::setWeight ( const double new_weight)

sets a new weight

◆ size()

template<typename T_DATA>
std::size_t gum::learning::DBRow< T_DATA >::size ( ) const
noexcept

returns the number of elements in the row

◆ weight() [1/2]

template<typename T_DATA>
const double & gum::learning::DBRow< T_DATA >::weight ( ) const
noexcept

returns the weight assigned to the DBRow

◆ weight() [2/2]

template<typename T_DATA>
double & gum::learning::DBRow< T_DATA >::weight ( )
noexcept

returns the weight assigned to the DBRow

Member Data Documentation

◆ row_

template<typename T_DATA>
std::vector< T_DATA > gum::learning::DBRow< T_DATA >::row_
protected

the row itself

Definition at line 190 of file DBRow.h.

◆ weight_

template<typename T_DATA>
double gum::learning::DBRow< T_DATA >::weight_ {1.0f}
protected

the weight of the row

Definition at line 193 of file DBRow.h.


The documentation for this class was generated from the following file: