37 #ifndef DOXYGEN_SHOULD_SKIP_THIS 62 const std::string& aLabel)
const {
66 GUM_ERROR(DuplicateElement,
"Label '" << aLabel <<
"' already exists");
74 const std::string& aDesc,
75 const Size nbrLabel) :
80 for (
Idx i = 0; i < nbrLabel; ++i) {
81 std::ostringstream oss;
88 const std::string& aDesc,
89 const std::vector< std::string >&
labels) :
94 for (
Idx i = 0; i < labels.size(); ++i)
127 if (&aLDRV !=
this) {
_copy(aLDRV); }
153 "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
Base class for discrete random variable.
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
gum is the global namespace for all aGrUM entities
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)
Base class for labelized discrete random variables.
void setAtPos(Idx i, const Key &newKey)
Change the value.
Class hash tables iterators.
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.