stream operator
parent
131f51a30c
commit
4027e86057
|
@ -26,12 +26,24 @@ using std::stringstream;
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
|
static void stream(std::ostream& os, const DiscreteValues& x,
|
||||||
|
const KeyFormatter& keyFormatter) {
|
||||||
|
for (const auto& kv : x)
|
||||||
|
os << "(" << keyFormatter(kv.first) << ", " << kv.second << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
|
std::ostream& operator<<(std::ostream& os, const DiscreteValues& x) {
|
||||||
|
stream(os, x, DefaultKeyFormatter);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
void DiscreteValues::print(const string& s,
|
void DiscreteValues::print(const string& s,
|
||||||
const KeyFormatter& keyFormatter) const {
|
const KeyFormatter& keyFormatter) const {
|
||||||
cout << s << ": ";
|
cout << s << ": ";
|
||||||
for (auto&& kv : *this)
|
stream(cout, *this, keyFormatter);
|
||||||
cout << "(" << keyFormatter(kv.first) << ", " << kv.second << ")";
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,9 @@ class GTSAM_EXPORT DiscreteValues : public Assignment<Key> {
|
||||||
/// @name Standard Interface
|
/// @name Standard Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
/// ostream operator:
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const DiscreteValues& x);
|
||||||
|
|
||||||
// insert in base class;
|
// insert in base class;
|
||||||
std::pair<iterator, bool> insert( const value_type& value ){
|
std::pair<iterator, bool> insert( const value_type& value ){
|
||||||
return Base::insert(value);
|
return Base::insert(value);
|
||||||
|
|
Loading…
Reference in New Issue