40 #ifndef DOXYGEN_SHOULD_SKIP_THIS 65 const std::string& aLabel)
const {
69 GUM_ERROR(DuplicateElement,
"Label '" << aLabel <<
"' already exists");
77 const std::string& aDesc,
78 const Size nbrLabel) :
83 for (
Idx i = 0; i < nbrLabel; ++i) {
84 std::ostringstream oss;
91 const std::string& aDesc,
92 const std::vector< std::string >&
labels) :
97 for (
Idx i = 0; i < labels.size(); ++i)
130 if (&aLDRV !=
this) {
_copy(aLDRV); }
156 "label '" << aLabel <<
"' is unknown in " << this->
toString());
virtual double numerical(Idx indice) const
get a numerical representation of he indice-the value.
std::vector< std::string > labels() const
vector of labels
Idx pos(const Key &key) const
Returns the position of the object passed in argument (if it exists).
void _copy(const Variable &aRV)
protected copy
void clear()
Clear the sequence.
void changeLabel(Idx pos, const std::string &aLabel) const
change a label for this index
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size size() const noexcept
Returns the size of the sequence.
virtual std::string label(Idx i) const
returns the ith label
virtual VarType varType() const
returns the type of variable
void eraseLabels()
erase all the labels
virtual Size domainSize() const
returns the size of the random discrete variable domain
virtual ~LabelizedVariable()
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool isLabel(const std::string &aLabel) const
indicates whether the variable already has the label passed in argument
void _copy(const LabelizedVariable &aLDRV)
copies the content of aLDRV
Sequence< std::string > __labels
the set of labels contained in the variable
bool exists(const Key &k) const
Check the existence of k in the sequence.
Idx posLabel(const std::string &label) const
return the pos from label
virtual LabelizedVariable * clone() const
a virtual clone ...
LabelizedVariable & operator=(const LabelizedVariable &aLDRV)
copy operator
LabelizedVariable()
(protected) Default constructor
DiscreteVariable()
(protected) Default constructor
const std::string toString() const
string version of *this
std::size_t Size
In aGrUM, hashed values are unsigned long int.
LabelizedVariable & addLabel(const std::string &aLabel)
add a label with a new index (we assume that we will NEVER remove a label)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void setAtPos(Idx i, const Key &newKey)
Change the value.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual Idx index(const std::string &label) const
returns the index of a given label
#define GUM_ERROR(type, msg)
const Key & atPos(Idx i) const
Returns the object at the pos i.
void insert(const Key &k)
Insert an element at the end of the sequence.