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