DiscreteValues::insert for single key-value pair
parent
8460452990
commit
dc79f492b2
|
|
@ -46,16 +46,22 @@ bool DiscreteValues::equals(const DiscreteValues& x, double tol) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* ************************************************************************ */
|
||||
DiscreteValues& DiscreteValues::insert(
|
||||
const std::pair<Key, size_t>& assignment) {
|
||||
if (count(assignment.first)) {
|
||||
throw std::out_of_range(
|
||||
"Requested to insert a DiscreteValues into another DiscreteValues "
|
||||
"that already contains one or more of its keys.");
|
||||
} else {
|
||||
this->emplace(assignment);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/* ************************************************************************ */
|
||||
DiscreteValues& DiscreteValues::insert(const DiscreteValues& values) {
|
||||
for (const auto& kv : values) {
|
||||
if (count(kv.first)) {
|
||||
throw std::out_of_range(
|
||||
"Requested to insert a DiscreteValues into another DiscreteValues "
|
||||
"that already contains one or more of its keys.");
|
||||
} else {
|
||||
this->emplace(kv);
|
||||
}
|
||||
this->insert(kv);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ class GTSAM_EXPORT DiscreteValues : public Assignment<Key> {
|
|||
return Base::insert(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert key-assignment pair.
|
||||
* Throws an invalid_argument exception if
|
||||
* any keys to be inserted are already used. */
|
||||
DiscreteValues& insert(const std::pair<Key, size_t>& assignment);
|
||||
|
||||
/** Insert all values from \c values. Throws an invalid_argument exception if
|
||||
* any keys to be inserted are already used. */
|
||||
DiscreteValues& insert(const DiscreteValues& values);
|
||||
|
|
|
|||
Loading…
Reference in New Issue