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