![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Container used to map discrete variables with nodes. More...
#include <variableNodeMap.h>
Public Member Functions | |
Constructors / Destructors | |
VariableNodeMap () | |
Default constructor. More... | |
VariableNodeMap (const VariableNodeMap &source) | |
Copy constructor Proceed a deep copy: all variables are copied but keep the same node id. More... | |
~VariableNodeMap () | |
Destructor. More... | |
VariableNodeMap & | operator= (const VariableNodeMap &source) |
Copy operator. More... | |
Getters and setters. | |
const DiscreteVariable & | get (NodeId id) const |
Returns a discrete variable given it's node id. More... | |
NodeId | get (const DiscreteVariable &var) const |
Returns a node id given it's variable. More... | |
bool | exists (NodeId id) const |
Return true if id matches a node. More... | |
bool | exists (const DiscreteVariable &var) const |
Return true if var matches a node. More... | |
NodeId | insert (NodeId id, const DiscreteVariable &var) |
Maps id with var. More... | |
void | erase (NodeId id) |
Removes a var and it's id of this mapping. The pointer is deleted. More... | |
void | erase (const DiscreteVariable &var) |
Removes a var and it's id of this mapping. The pointer is deleted. More... | |
void | changeName (NodeId id, const std::string &new_name) |
we allow the user to change the name of a variable More... | |
void | clear () |
removes all the associations More... | |
std::string | toString () const |
friendly displays the content of the VariableNodeMap More... | |
const std::string & | name (NodeId id) const |
Returns the name of a variable given its id. More... | |
const std::string & | name (const DiscreteVariable &var) const |
Returns the name of a variable. More... | |
Operators. | |
const DiscreteVariable & | operator[] (NodeId id) const |
Returns a discrete variable given it's node id. More... | |
NodeId | operator[] (const DiscreteVariable &var) const |
Returns a node id given it's variable. More... | |
Accessor by name | |
NodeId | idFromName (const std::string &name) const |
const DiscreteVariable & | variableFromName (const std::string &name) const |
Container used to map discrete variables with nodes.
Definition at line 48 of file variableNodeMap.h.
gum::VariableNodeMap::VariableNodeMap | ( | ) |
Default constructor.
gum::VariableNodeMap::VariableNodeMap | ( | const VariableNodeMap & | source | ) |
Copy constructor Proceed a deep copy: all variables are copied but keep the same node id.
gum::VariableNodeMap::~VariableNodeMap | ( | ) |
Destructor.
|
private |
effectively do the copy (for copy constructor or operator=)
void gum::VariableNodeMap::changeName | ( | NodeId | id, |
const std::string & | new_name | ||
) |
we allow the user to change the name of a variable
DuplicateLabel | if this name already exists |
NotFound | Raised if no nodes matches id. |
void gum::VariableNodeMap::clear | ( | ) |
removes all the associations
void gum::VariableNodeMap::erase | ( | NodeId | id | ) |
Removes a var and it's id of this mapping. The pointer is deleted.
NotFound | Raised if no nodes matches id. |
void gum::VariableNodeMap::erase | ( | const DiscreteVariable & | var | ) |
Removes a var and it's id of this mapping. The pointer is deleted.
NotFound | Raised if no nodes matches id. |
bool gum::VariableNodeMap::exists | ( | const DiscreteVariable & | var | ) | const |
Return true if var matches a node.
const DiscreteVariable& gum::VariableNodeMap::get | ( | NodeId | id | ) | const |
Returns a discrete variable given it's node id.
NotFound | Raised if no nodes matches id. |
NodeId gum::VariableNodeMap::get | ( | const DiscreteVariable & | var | ) | const |
Returns a node id given it's variable.
NotFound | Raised if no nodes matches var. |
NodeId gum::VariableNodeMap::idFromName | ( | const std::string & | name | ) | const |
NotFound | if no such name exists in the graph. |
NodeId gum::VariableNodeMap::insert | ( | NodeId | id, |
const DiscreteVariable & | var | ||
) |
Maps id with var.
DuplicateLabel | if this name already exists |
DuplicateElement | if this id already exists |
const std::string& gum::VariableNodeMap::name | ( | NodeId | id | ) | const |
Returns the name of a variable given its id.
id | The variable's id. |
NotFound | Raised if no variable matches id. |
const std::string& gum::VariableNodeMap::name | ( | const DiscreteVariable & | var | ) | const |
Returns the name of a variable.
var | The variable. |
NotFound | Raised if var is not in this VariableNodeMap. |
VariableNodeMap& gum::VariableNodeMap::operator= | ( | const VariableNodeMap & | source | ) |
Copy operator.
const DiscreteVariable& gum::VariableNodeMap::operator[] | ( | NodeId | id | ) | const |
Returns a discrete variable given it's node id.
NotFound | Raised if no nodes matches id. |
NodeId gum::VariableNodeMap::operator[] | ( | const DiscreteVariable & | var | ) | const |
Returns a node id given it's variable.
NotFound | Raised if no nodes matches var. |
std::string gum::VariableNodeMap::toString | ( | ) | const |
friendly displays the content of the VariableNodeMap
const DiscreteVariable& gum::VariableNodeMap::variableFromName | ( | const std::string & | name | ) | const |
NotFound | if no such name exists in the graph. |
HashTable for easely find an id from a name.
Definition at line 167 of file variableNodeMap.h.
|
private |
Bijection between the node's NodeIds and the variables.
Definition at line 164 of file variableNodeMap.h.