aGrUM  0.13.2
gum::learning::DBRow< T_DATA, ALLOC > Class Template Reference

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

#include <agrum/learning/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=1.0, 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 53 of file DBRow.h.

Member Typedef Documentation

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

Constructor & Destructor Documentation

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

default constructor

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

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

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 = 1.0,
const ALLOC< T_DATA > &  alloc = ALLOC< T_DATA >() 
)

constructor with a given size for the row

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

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

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

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

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

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

move constructor

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

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

destructor

Member Function Documentation

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

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

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

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

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

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.
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.
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

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

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

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

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)

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)

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)

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)

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

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

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

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

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

Member Data Documentation

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

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


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