aGrUM  0.14.1
gum::learning::IdSet< ALLOC > Class Template Reference

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

#include <agrum/learning/scores_and_tests/idSet.h>

Inherits ALLOC< NodeId >.

Public Member Functions

Constructors / Destructors
 IdSet (const allocator_type &alloc=allocator_type())
 default constructor More...
 
 IdSet (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...
 
 IdSet (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...
 
 IdSet (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...
 
 IdSet (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...
 
 IdSet (const IdSet< ALLOC > &from)
 copy constructor More...
 
 IdSet (const IdSet< ALLOC > &from, const allocator_type &alloc)
 copy constructor with a given allocator More...
 
 IdSet (IdSet< ALLOC > &&from)
 move constructor More...
 
 IdSet (IdSet< ALLOC > &&from, const allocator_type &alloc)
 move constructor with a given allocator More...
 
virtual IdSet< ALLOC > * clone () const
 virtual copy constructor More...
 
virtual IdSet< ALLOC > * clone (const allocator_type &alloc) const
 virtual copy constructor with a given allocator More...
 
virtual ~IdSet ()
 destructor More...
 
Operators
IdSet< ALLOC > & operator= (const IdSet< ALLOC > &from)
 copy operator More...
 
IdSet< ALLOC > & operator= (IdSet< 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 IdSet< ALLOC > &from) const
 returns true if both sets are equal More...
 
bool operator!= (const IdSet< 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...
 
IdSet< ALLOC > conditionalIdSet () 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 IdSet< ALLOC > &set) const
 indicates whether the IdSet contains the IdSet passed in argument More...
 
void clear ()
 removes all the nodes from the IdSet 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 IdSet More...
 
bool exists (const NodeId id) const
 indicates whether a given id is contained in the IdSet 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 IdSet 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 = IdSetIterator< ALLOC >
 
using const_iterator = IdSetIterator< ALLOC >
 
using iterator_safe = IdSetIterator< ALLOC >
 
using const_iterator_safe = IdSetIterator< ALLOC >
 

Detailed Description

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

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

IdSets 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. IdSets fix this issue.

Definition at line 45 of file idSet.h.

Member Typedef Documentation

◆ allocator_type

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

type for the allocators passed in arguments of methods

Definition at line 197 of file idSet.h.

◆ const_iterator

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdSet< ALLOC >::const_iterator = IdSetIterator< ALLOC >

Definition at line 200 of file idSet.h.

◆ const_iterator_safe

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdSet< ALLOC >::const_iterator_safe = IdSetIterator< ALLOC >

Definition at line 202 of file idSet.h.

◆ iterator

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdSet< ALLOC >::iterator = IdSetIterator< ALLOC >

Definition at line 199 of file idSet.h.

◆ iterator_safe

template<template< typename > class ALLOC = std::allocator>
using gum::learning::IdSet< ALLOC >::iterator_safe = IdSetIterator< ALLOC >

Definition at line 201 of file idSet.h.

Constructor & Destructor Documentation

◆ IdSet() [1/9]

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

default constructor

◆ IdSet() [2/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdSet< ALLOC >::IdSet ( 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 IdSet

◆ IdSet() [3/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdSet< ALLOC >::IdSet ( 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 IdSet

◆ IdSet() [4/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdSet< ALLOC >::IdSet ( 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 IdSet

◆ IdSet() [5/9]

template<template< typename > class ALLOC = std::allocator>
gum::learning::IdSet< ALLOC >::IdSet ( 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 IdSet

◆ IdSet() [6/9]

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

copy constructor

◆ IdSet() [7/9]

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

copy constructor with a given allocator

◆ IdSet() [8/9]

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

move constructor

◆ IdSet() [9/9]

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

move constructor with a given allocator

◆ ~IdSet()

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

destructor

Member Function Documentation

◆ begin()

template<template< typename > class ALLOC = std::allocator>
iterator gum::learning::IdSet< 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::IdSet< 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::IdSet< ALLOC >::clear ( )

removes all the nodes from the IdSet

◆ clone() [1/2]

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

virtual copy constructor

◆ clone() [2/2]

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

virtual copy constructor with a given allocator

◆ conditionalIdSet()

template<template< typename > class ALLOC = std::allocator>
IdSet< ALLOC > gum::learning::IdSet< ALLOC >::conditionalIdSet ( ) const

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

◆ contains()

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

indicates whether the IdSet contains the IdSet passed in argument

◆ empty()

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

indicates whether the IdSet contains some nodes or not

◆ end()

template<template< typename > class ALLOC = std::allocator>
const iterator& gum::learning::IdSet< 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::IdSet< 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::IdSet< 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::IdSet< ALLOC >::exists ( const NodeId  id) const

indicates whether a given id is contained in the IdSet

◆ getAllocator()

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

returns the allocator used

◆ hasConditioningSet()

template<template< typename > class ALLOC = std::allocator>
bool gum::learning::IdSet< 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::IdSet< ALLOC >::ids ( ) const

returns the set of ids

◆ nbLHSIds()

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

returns the number of left hand side ids

◆ nbRHSIds()

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

returns the number of right hand side ids

◆ operator!=()

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

returns true if the sets differ

◆ operator=() [1/2]

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

copy operator

◆ operator=() [2/2]

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

move operator

◆ operator==()

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

returns true if both sets are equal

◆ operator[]()

template<template< typename > class ALLOC = std::allocator>
NodeId gum::learning::IdSet< 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::IdSet< ALLOC >::pos ( const NodeId  id) const

returns the position of a given node in the IdSet

Exceptions
NotFoundRaised if the element does not exist.

◆ size()

template<template< typename > class ALLOC = std::allocator>
std::size_t gum::learning::IdSet< 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::IdSet< ALLOC >::toString ( ) const

returns the content of the set as a string


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