libDAI
|
Represents a set of variables. More...
#include <dai/varset.h>
Public Member Functions | |
Constructors and destructors | |
VarSet () | |
Default constructor (constructs an empty set) | |
VarSet (const SmallSet< Var > &x) | |
Construct from SmallSet<Var> x. | |
VarSet (const Var &v) | |
Construct a VarSet with one element, v. | |
VarSet (const Var &v1, const Var &v2) | |
Construct a VarSet with two elements, v1 and v2. | |
template<typename VarIterator > | |
VarSet (VarIterator begin, VarIterator end, size_t sizeHint=0) | |
Construct a VarSet from the range between begin and end. | |
Queries | |
BigInt | nrStates () const |
Calculates the number of states of this VarSet, which is simply the number of possible joint states of the variables in *this . | |
![]() | |
SmallSet () | |
Default constructor (constructs an empty set) | |
SmallSet (const Var &t) | |
Construct a set consisting of one element. | |
SmallSet (const Var &t1, const Var &t2) | |
Construct a set consisting of two elements. | |
SmallSet (TIterator begin, TIterator end, size_t sizeHint) | |
Construct a SmallSet from a range of elements. | |
SmallSet & | insert (const Var &t) |
Inserts t into *this . | |
SmallSet & | erase (const Var &t) |
Erases t from *this . | |
SmallSet | operator/ (const SmallSet &x) const |
Set-minus operator: returns all elements in *this , except those in x. | |
SmallSet | operator| (const SmallSet &x) const |
Set-union operator: returns all elements in *this , plus those in x. | |
SmallSet | operator& (const SmallSet &x) const |
Set-intersection operator: returns all elements in *this that are also contained in x. | |
SmallSet & | operator/= (const SmallSet &x) |
Erases from *this all elements in x. | |
SmallSet & | operator/= (const Var &t) |
Erases one element. | |
SmallSet & | operator|= (const SmallSet &x) |
Adds to *this all elements in x. | |
SmallSet & | operator|= (const Var &t) |
Adds one element. | |
SmallSet & | operator&= (const SmallSet &x) |
Erases from *this all elements not in x. | |
bool | operator<< (const SmallSet &x) const |
Returns true if *this is a subset of x. | |
bool | operator>> (const SmallSet &x) const |
Returns true if x is a subset of *this . | |
bool | intersects (const SmallSet &x) const |
Returns true if *this and x have elements in common. | |
bool | contains (const Var &t) const |
Returns true if *this contains the element t. | |
std::vector< Var >::size_type | size () const |
Returns number of elements. | |
bool | empty () const |
Returns whether *this is empty. | |
std::vector< Var > & | elements () |
Returns reference to the elements. | |
const std::vector< Var > & | elements () const |
Returns constant reference to the elements. | |
iterator | begin () |
Returns iterator that points to the first element. | |
const_iterator | begin () const |
Returns constant iterator that points to the first element. | |
iterator | end () |
Returns iterator that points beyond the last element. | |
const_iterator | end () const |
Returns constant iterator that points beyond the last element. | |
reverse_iterator | rbegin () |
Returns reverse iterator that points to the last element. | |
const_reverse_iterator | rbegin () const |
Returns constant reverse iterator that points to the last element. | |
reverse_iterator | rend () |
Returns reverse iterator that points beyond the first element. | |
const_reverse_iterator | rend () const |
Returns constant reverse iterator that points beyond the first element. | |
Var & | front () |
Returns reference to first element. | |
const Var & | front () const |
Returns constant reference to first element. | |
Var & | back () |
Returns reference to last element. | |
const Var & | back () const |
Returns constant reference to last element. |
Friends | |
Input and output | |
std::ostream & | operator<< (std::ostream &os, const VarSet &vs) |
Writes a VarSet to an output stream. | |
Streaming input/output | |
Comparison operators |
Additional Inherited Members | |
![]() | |
typedef std::vector< Var > ::const_iterator | const_iterator |
Constant iterator over the elements. | |
typedef std::vector< Var > ::iterator | iterator |
Iterator over the elements. | |
typedef std::vector< Var > ::const_reverse_iterator | const_reverse_iterator |
Constant reverse iterator over the elements. | |
typedef std::vector< Var > ::reverse_iterator | reverse_iterator |
Reverse iterator over the elements. |
Represents a set of variables.
|
inline |
Default constructor (constructs an empty set)
Construct a VarSet with two elements, v1 and v2.
|
inline |
|
inline |
Calculates the number of states of this VarSet, which is simply the number of possible joint states of the variables in *this
.
The number of states of the Cartesian product of the variables in this VarSet is simply the product of the number of states of each variable in this VarSet. If *this
corresponds with the set , where variable
has label
, and denoting by
the number of possible values ("states") of variable
, the number of joint configurations of the variables in
is given by
.
|
friend |
Writes a VarSet to an output stream.