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

A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set. More...

#include <idCondSet.h>

Inherits ALLOC< NodeId >.

Public Member Functions

Constructors / Destructors
 IdCondSet (const allocator_type &alloc=allocator_type())
 default constructor More...
 
 IdCondSet (const std::vector< NodeId, ALLOC< NodeId > > &ids, const bool rhs_ids, const bool ordered_ids, const allocator_type &alloc=allocator_type())
 default constructor with no variable on the left side More...
 
 IdCondSet (NodeId var1, const std::vector< NodeId, ALLOC< NodeId > > &rhs_ids, const bool ordered_rhs_ids=false, const allocator_type &alloc=allocator_type())
 default constructor with one variable on the left side More...
 
 IdCondSet (NodeId var1, NodeId var2, const std::vector< NodeId, ALLOC< NodeId > > &rhs_ids, const bool ordered_lhs_vars, const bool ordered_rhs_ids=false, const allocator_type &alloc=allocator_type())
 default constructor with two variables on the left side More...
 
 IdCondSet (NodeId var1, NodeId var2, NodeId var3, const std::vector< NodeId, ALLOC< NodeId > > &rhs_ids, const bool ordered_lhs_vars, const bool ordered_rhs_ids=false, const allocator_type &alloc=allocator_type())
 default constructor with three variables on the left side More...
 
 IdCondSet (const IdCondSet< ALLOC > &from)
 copy constructor More...
 
 IdCondSet (const IdCondSet< ALLOC > &from, const allocator_type &alloc)
 copy constructor with a given allocator More...
 
 IdCondSet (IdCondSet< ALLOC > &&from)
 move constructor More...
 
 IdCondSet (IdCondSet< ALLOC > &&from, const allocator_type &alloc)
 move constructor with a given allocator More...
 
virtual IdCondSet< ALLOC > * clone () const
 virtual copy constructor More...
 
virtual IdCondSet< ALLOC > * clone (const allocator_type &alloc) const
 virtual copy constructor with a given allocator More...
 
virtual ~IdCondSet ()
 destructor More...
 
Operators
IdCondSet< ALLOC > & operator= (const IdCondSet< ALLOC > &from)
 copy operator More...
 
IdCondSet< ALLOC > & operator= (IdCondSet< ALLOC > &&from)
 move operator More...
 
NodeId operator[] (const std::size_t index) const
 returns the node id stored at a given index More...
 
bool operator== (const IdCondSet< ALLOC > &from) const
 returns true if both sets are equal More...
 
bool operator!= (const IdCondSet< ALLOC > &from) const
 returns true if the sets differ More...
 
Iterators
iterator_safe beginSafe () const
 Returns a safe begin iterator. More...
 
const iterator_safeendSafe () const
 Returns the safe end iterator. More...
 
iterator begin () const
 Returns an unsafe begin iterator. More...
 
const iteratorend () const
 Returns the unsafe end iterator. More...
 
Accessors / Modifiers
const Sequence< NodeId, ALLOC< NodeId > > & ids () const
 returns the set of ids More...
 
IdCondSet< ALLOC > conditionalIdCondSet () const
 returns the idSet at the right hand side of the conditioning bar More...
 
std::size_t nbLHSIds () const
 returns the number of left hand side ids More...
 
std::size_t nbRHSIds () const
 returns the number of right hand side ids More...
 
bool contains (const IdCondSet< ALLOC > &set) const
 indicates whether the IdCondSet contains the IdCondSet passed in argument More...
 
void clear ()
 removes all the nodes from the IdCondSet More...
 
std::size_t size () const
 returns the number of variables (both left and right hand side) More...
 
std::size_t pos (const NodeId id) const
 returns the position of a given node in the IdCondSet More...
 
bool exists (const NodeId id) const
 indicates whether a given id is contained in the IdCondSet More...
 
void erase (const NodeId id)
 erase a node in the idset More...
 
bool hasConditioningSet () const
 indicates whether the idset contains a non-empty conditioning set More...
 
bool empty () const
 indicates whether the IdCondSet contains some nodes or not More...
 
std::string toString () const
 returns the content of the set as a string More...
 
allocator_type getAllocator () const
 returns the allocator used More...
 

Public Types

using allocator_type = ALLOC< NodeId >
 type for the allocators passed in arguments of methods More...
 
using iterator = IdCondSetIterator< ALLOC >
 
using const_iterator = IdCondSetIterator< ALLOC >
 
using iterator_safe = IdCondSetIterator< ALLOC >
 
using const_iterator_safe = IdCondSetIterator< ALLOC >
 

Detailed Description

template<template< typename > class ALLOC = std::allocator>
class gum::learning::IdCondSet< ALLOC >

A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set.

IdCondSets are used by learning caches to store pairs of sets of nodes, the second ones represent typically conditional sets. This is useful for storing in hashtables the scores assigned to sets of nodes given other nodes. NodeSets are actually not well suited for this purpose because their implementations makes the computation of their hash values quite difficult. IdCondSets fix this issue.

Definition at line 47 of file idCondSet.h.

Member Typedef Documentation

◆ allocator_type

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdCondSet< ALLOC >::allocator_type = ALLOC< NodeId >

type for the allocators passed in arguments of methods

Definition at line 200 of file idCondSet.h.

◆ const_iterator

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdCondSet< ALLOC >::const_iterator = IdCondSetIterator< ALLOC >

Definition at line 203 of file idCondSet.h.

◆ const_iterator_safe

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdCondSet< ALLOC >::const_iterator_safe = IdCondSetIterator< ALLOC >

Definition at line 205 of file idCondSet.h.

◆ iterator

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdCondSet< ALLOC >::iterator = IdCondSetIterator< ALLOC >

Definition at line 202 of file idCondSet.h.

◆ iterator_safe

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdCondSet< ALLOC >::iterator_safe = IdCondSetIterator< ALLOC >

Definition at line 204 of file idCondSet.h.

Constructor & Destructor Documentation

◆ IdCondSet() [1/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdCondSet< ALLOC >::IdCondSet ( const allocator_type alloc = allocator_type())

default constructor

◆ IdCondSet() [2/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdCondSet< ALLOC >::IdCondSet ( const std::vector< NodeId, ALLOC< NodeId > > &  ids,
const bool  rhs_ids,
const bool  ordered_ids,
const allocator_type alloc = allocator_type() 
)

default constructor with no variable on the left side

Parameters
idsthe set of variables
rhs_idsindicate whether the ids are on the right side of the conditioning bar or not
ordered_idsindicates whether the ids in rhs_ids should be considered as an ordered set or an unordered set
allocthe allocator used to store the data in the IdCondSet

◆ IdCondSet() [3/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdCondSet< ALLOC >::IdCondSet ( NodeId  var1,
const std::vector< NodeId, ALLOC< NodeId > > &  rhs_ids,
const bool  ordered_rhs_ids = false,
const allocator_type alloc = allocator_type() 
)

default constructor with one variable on the left side

Parameters
var1the variable on the left side of the conditioning bar
rhs_idsthe set of variables on the right side of the conditioning bar
ordered_rhs_idsindicates whether the ids in rhs_ids should be considered as an ordered set or an unordered set
allocthe allocator used to store the data in the IdCondSet

◆ IdCondSet() [4/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdCondSet< ALLOC >::IdCondSet ( NodeId  var1,
NodeId  var2,
const std::vector< NodeId, ALLOC< NodeId > > &  rhs_ids,
const bool  ordered_lhs_vars,
const bool  ordered_rhs_ids = false,
const allocator_type alloc = allocator_type() 
)

default constructor with two variables on the left side

Parameters
var1the 1st variable on the left side of the conditioning bar
var2the 2nd variable on the left side of the conditioning bar
rhs_idsthe set of variables on the right side of the conditioning bar
ordered_lhs_varsa Boolean indicating whether {var1,var2} should be considered as an ordered set or not. Typically, in an independence test, this set is unordered. When set to false,
ordered_rhs_idsindicates whether the ids in rhs_ids should be considered as an ordered set or an unordered set
ordered_rhs_ids
allocthe allocator used to store the data in the IdCondSet

◆ IdCondSet() [5/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdCondSet< ALLOC >::IdCondSet ( NodeId  var1,
NodeId  var2,
NodeId  var3,
const std::vector< NodeId, ALLOC< NodeId > > &  rhs_ids,
const bool  ordered_lhs_vars,
const bool  ordered_rhs_ids = false,
const allocator_type alloc = allocator_type() 
)

default constructor with three variables on the left side

Parameters
var1the 1st variable on the left side of the conditioning bar
var2the 2nd variable on the left side of the conditioning bar
var3the 3rd variable on the left side of the conditioning bar
rhs_idsthe set of variables on the right side of the conditioning bar
ordered_varsa Boolean indicating whether {var1,var2,var3} should be considered as an ordered set or not.
ordered_rhs_idsindicates whether the ids in rhs_ids should be considered as an ordered set or an unordered set
allocthe allocator used to store the data in the IdCondSet

◆ IdCondSet() [6/9]

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

copy constructor

◆ IdCondSet() [7/9]

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

copy constructor with a given allocator

◆ IdCondSet() [8/9]

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

move constructor

◆ IdCondSet() [9/9]

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

move constructor with a given allocator

◆ ~IdCondSet()

template<template< typename > class ALLOC = std::allocator>
virtual gum::learning::IdCondSet< ALLOC >::~IdCondSet ( )
virtual

destructor

Member Function Documentation

◆ begin()

template<template< typename > class ALLOC = std::allocator>
iterator gum::learning::IdCondSet< ALLOC >::begin ( ) const

Returns an unsafe begin iterator.

Returns
Returns an unsafe begin iterator.

◆ beginSafe()

template<template< typename > class ALLOC = std::allocator>
iterator_safe gum::learning::IdCondSet< ALLOC >::beginSafe ( ) const

Returns a safe begin iterator.

Returns
Returns a safe begin iterator.

◆ clear()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::IdCondSet< ALLOC >::clear ( )

removes all the nodes from the IdCondSet

◆ clone() [1/2]

template<template< typename > class ALLOC = std::allocator>
virtual IdCondSet< ALLOC >* gum::learning::IdCondSet< ALLOC >::clone ( ) const
virtual

virtual copy constructor

◆ clone() [2/2]

template<template< typename > class ALLOC = std::allocator>
virtual IdCondSet< ALLOC >* gum::learning::IdCondSet< ALLOC >::clone ( const allocator_type alloc) const
virtual

virtual copy constructor with a given allocator

◆ conditionalIdCondSet()

template<template< typename > class ALLOC = std::allocator>
IdCondSet< ALLOC > gum::learning::IdCondSet< ALLOC >::conditionalIdCondSet ( ) const

returns the idSet at the right hand side of the conditioning bar

◆ contains()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::contains ( const IdCondSet< ALLOC > &  set) const

indicates whether the IdCondSet contains the IdCondSet passed in argument

◆ empty()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::empty ( ) const

indicates whether the IdCondSet contains some nodes or not

◆ end()

template<template< typename > class ALLOC = std::allocator>
const iterator& gum::learning::IdCondSet< ALLOC >::end ( ) const

Returns the unsafe end iterator.

Returns
Returns the unsafe end iterator.

◆ endSafe()

template<template< typename > class ALLOC = std::allocator>
const iterator_safe& gum::learning::IdCondSet< ALLOC >::endSafe ( ) const

Returns the safe end iterator.

Returns
Returns the safe end iterator.

◆ erase()

template<template< typename > class ALLOC = std::allocator>
void gum::learning::IdCondSet< ALLOC >::erase ( const NodeId  id)

erase a node in the idset

If the element cannot be found, the function does nothing. In particular, it throws no exception.

◆ exists()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::exists ( const NodeId  id) const

indicates whether a given id is contained in the IdCondSet

◆ getAllocator()

template<template< typename > class ALLOC = std::allocator>
allocator_type gum::learning::IdCondSet< ALLOC >::getAllocator ( ) const

returns the allocator used

◆ hasConditioningSet()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::hasConditioningSet ( ) const

indicates whether the idset contains a non-empty conditioning set

◆ ids()

template<template< typename > class ALLOC = std::allocator>
const Sequence< NodeId, ALLOC< NodeId > >& gum::learning::IdCondSet< ALLOC >::ids ( ) const

returns the set of ids

◆ nbLHSIds()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::IdCondSet< ALLOC >::nbLHSIds ( ) const

returns the number of left hand side ids

◆ nbRHSIds()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::IdCondSet< ALLOC >::nbRHSIds ( ) const

returns the number of right hand side ids

◆ operator!=()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::operator!= ( const IdCondSet< ALLOC > &  from) const

returns true if the sets differ

◆ operator=() [1/2]

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

copy operator

◆ operator=() [2/2]

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

move operator

◆ operator==()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdCondSet< ALLOC >::operator== ( const IdCondSet< ALLOC > &  from) const

returns true if both sets are equal

◆ operator[]()

template<template< typename > class ALLOC = std::allocator>
NodeId gum::learning::IdCondSet< ALLOC >::operator[] ( const std::size_t  index) const

returns the node id stored at a given index

◆ pos()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::IdCondSet< ALLOC >::pos ( const NodeId  id) const

returns the position of a given node in the IdCondSet

Exceptions
NotFoundRaised if the element does not exist.

◆ size()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::IdCondSet< ALLOC >::size ( ) const

returns the number of variables (both left and right hand side)

◆ toString()

template<template< typename > class ALLOC = std::allocator>
std::string gum::learning::IdCondSet< ALLOC >::toString ( ) const

returns the content of the set as a string


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