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

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

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

+ Collaboration diagram for gum::learning::DBRow< T_DATA, ALLOC >:

Public Member Functions

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

Public Types

using allocator_type = ALLOC< T_DATA >
 

Protected Attributes

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

Friends

template<typename TX_DATA , template< typename > class OTHER_ALLOC>
class DBRow
 

Detailed Description

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
class gum::learning::DBRow< T_DATA, ALLOC >

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 54 of file DBRow.h.

Member Typedef Documentation

◆ allocator_type

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
using gum::learning::DBRow< T_DATA, ALLOC >::allocator_type = ALLOC< T_DATA >

Definition at line 56 of file DBRow.h.

Constructor & Destructor Documentation

◆ DBRow() [1/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( )

default constructor

◆ DBRow() [2/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( const ALLOC< T_DATA > &  alloc)

default constructor with specific allocator

◆ DBRow() [3/11]

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

constructs a row of a given size with missing values

◆ DBRow() [4/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( const std::size_t  size,
const T_DATA  default_value,
const double  weight,
const ALLOC< T_DATA > &  alloc = ALLOC< T_DATA >() 
)

constructor with a given size for the row

◆ DBRow() [5/11]

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

initializer list constructor

◆ DBRow() [6/11]

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

initializer from a vector of cells

◆ DBRow() [7/11]

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

initializer with a move from a vector of cells

◆ DBRow() [8/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( const DBRow< T_DATA, ALLOC > &  from)

copy constructor

◆ DBRow() [9/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( const DBRow< T_DATA, ALLOC > &  from,
const ALLOC< T_DATA > &  alloc 
)

copy constructor with a given allocator

◆ DBRow() [10/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( DBRow< T_DATA, ALLOC > &&  from)

move constructor

◆ DBRow() [11/11]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::DBRow ( DBRow< T_DATA, ALLOC > &&  from,
const ALLOC< T_DATA > &  alloc 
)

move constructor with a given allocator

◆ ~DBRow()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
gum::learning::DBRow< T_DATA, ALLOC >::~DBRow ( )

destructor

Member Function Documentation

◆ clone() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
DBRow< T_DATA, ALLOC >* gum::learning::DBRow< T_DATA, ALLOC >::clone ( ) const

virtual copy constructor

◆ clone() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
DBRow< T_DATA, ALLOC >* gum::learning::DBRow< T_DATA, ALLOC >::clone ( const ALLOC< T_DATA > &  alloc) const

virtual copy constructor with a given allocator

◆ getAllocator()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
ALLOC< T_DATA > gum::learning::DBRow< T_DATA, ALLOC >::getAllocator ( ) const

returns the allocator used by the DBRow

◆ operator=() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
DBRow< T_DATA, ALLOC >& gum::learning::DBRow< T_DATA, ALLOC >::operator= ( const DBRow< T_DATA, ALLOC > &  from)

copy operator

◆ operator=() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
DBRow< T_DATA, ALLOC >& gum::learning::DBRow< T_DATA, ALLOC >::operator= ( DBRow< T_DATA, ALLOC > &&  from)

move operator

◆ operator[]() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
T_DATA& gum::learning::DBRow< T_DATA, ALLOC >::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, template< typename > class ALLOC = std::allocator>
const T_DATA& gum::learning::DBRow< T_DATA, ALLOC >::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, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::pushBack ( const T_DATA &  elt)

adds a new element at the end of the row

◆ pushBack() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::pushBack ( T_DATA &&  elt)

adds a new element at the end of the row

◆ reserve()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::reserve ( const std::size_t  new_size)

reserve a size for the elements of a given row

◆ resize()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::resize ( const std::size_t  new_size)

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

◆ row() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
const std::vector< T_DATA, ALLOC< T_DATA > >& gum::learning::DBRow< T_DATA, ALLOC >::row ( ) const
noexcept

returns the current row (without the weight)

◆ row() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
std::vector< T_DATA, ALLOC< T_DATA > >& gum::learning::DBRow< T_DATA, ALLOC >::row ( )
noexcept

returns the current row (without the weight)

◆ setRow() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
template<template< typename > class OTHER_ALLOC>
void gum::learning::DBRow< T_DATA, ALLOC >::setRow ( const std::vector< T_DATA, OTHER_ALLOC< T_DATA > > &  new_row)

sets a new row (without changing the weight)

◆ setRow() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::setRow ( std::vector< T_DATA, ALLOC< T_DATA > > &&  new_row)

sets a new row (without changing the weight)

◆ setWeight()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
void gum::learning::DBRow< T_DATA, ALLOC >::setWeight ( const double  new_weight)

sets a new weight

◆ size()

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::DBRow< T_DATA, ALLOC >::size ( ) const
noexcept

returns the number of elements in the row

◆ weight() [1/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
const double& gum::learning::DBRow< T_DATA, ALLOC >::weight ( ) const
noexcept

returns the weight assigned to the DBRow

◆ weight() [2/2]

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
double& gum::learning::DBRow< T_DATA, ALLOC >::weight ( )
noexcept

returns the weight assigned to the DBRow

Friends And Related Function Documentation

◆ DBRow

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
template<typename TX_DATA , template< typename > class OTHER_ALLOC>
friend class DBRow
friend

Definition at line 206 of file DBRow.h.

Member Data Documentation

◆ row_

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
std::vector< T_DATA, ALLOC< T_DATA > > gum::learning::DBRow< T_DATA, ALLOC >::row_
protected

the row itself

Definition at line 199 of file DBRow.h.

◆ weight_

template<typename T_DATA, template< typename > class ALLOC = std::allocator>
double gum::learning::DBRow< T_DATA, ALLOC >::weight_ {1.0f}
protected

the weight of the row

Definition at line 202 of file DBRow.h.


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